Re: NSString escaping single quotes
Re: NSString escaping single quotes
- Subject: Re: NSString escaping single quotes
- From: Michael Sullivan <email@hidden>
- Date: Mon, 19 Mar 2007 23:07:32 +0900
Hi Sean,
Thanks, that make sense, but I wasn't sure. I'll look elsewhere for
the problem.
Mike
On Mar 19, 2007, at 22:40 , Sean Murphy wrote:
On Mar 19, 2007, at 5:33 AM, Michael Sullivan wrote:
...
The debugger reveals that the string is constructed with a \ in
front of the ' characters which contain the string for the SQL
statement. I suspect this is causing the SQL parser to hang.
The string is declared like this:
NSString *sql = [NSString stringWithFormat:@"select * from t_state
where state_code = '%@'", code];
The contents of the string being passed is this:
select * from t_state where state_code = \'xx\'
So, how do I get rid of the \ in front of the single quotes?
Hi Michael,
The backslash-escaped single quotes only seem to appear inside of
the Xcode debugger window's variable summary column. Examining the
value of "sql" manually in gdb reveals the correct format:
(gdb) po sql
select * from t_state where state_code = 'XX'
and NSLogging the string also leaves out the backslashes. So, I'd
say those single quotes are escaped for some reason only in the
process of Xcode formatting the object for display in the variable
view.
-Sean
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden