• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSString escaping single quotes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >NSString escaping single quotes (From: Michael Sullivan <email@hidden>)
 >Re: NSString escaping single quotes (From: Sean Murphy <email@hidden>)

  • Prev by Date: Re: NSString escaping single quotes
  • Next by Date: Re: Setting the Key window after sheet ends
  • Previous by thread: Re: NSString escaping single quotes
  • Next by thread: Parsing "Set-Cookie" HTTP Response
  • Index(es):
    • Date
    • Thread