Re: NSStrings to CStrings and hex encoding...
Re: NSStrings to CStrings and hex encoding...
- Subject: Re: NSStrings to CStrings and hex encoding...
- From: Roland King <email@hidden>
- Date: Wed, 25 Jun 2014 10:32:56 +0800
well the 'problem' is that the quotation marks you have in there aren't the usual 0x27 simple quotes but the pretty left/right quote marks which are unicode U+2018 and U+2019. 0xE28098 is the UTF-8 representation of the first of those, 0xE28099 is the encoding of the second one.
So either the textview is returning a different string than it was before, or the string conversion is returning a different answer in that case. First thing is probably to work out which of those two cases it is, different output from text view or different string encode.
Have you tried [ string dataUsingEncoding:NSAsciiStringEncoding allowLossyConversion:YES ] ? Although that comes with its own set of sharp edges.
On 25 Jun, 2014, at 10:15 am, Andrew Satori <email@hidden> wrote:
> Alright, I am stumped so I am asking for help (and it is annoying me because I am 100% certain that the answer will be stupid simple).
>
> I have a bit of code (old code I might add) that I am updating to ARC and other such modern features. Unfortunately, I have run into a little snag. The code calls out to a C library that expects good old fahsioned C Strings of the UCHAR * variety. In prior versions of OS X and Cocoa cStringUsingEncoding would return the string and things would be ducky. However, starting with Mavericks and Xcode 5 I am seeing a problem where the resulting char * is encoding characters to hex representations. So for example, the following NSString taken from an NSTextView content
>
> NSString myValue = "select * from some_table where column_name = 'value'"
>
> becomes
>
> (UCHAR *)szValue = "select * from some_table where column_name = \xe2\x80\x98value\xe2\x80\x99"
>
> Even more disturbing is that it only happens when typed into the NSTextView. Pasting the above NSString value into the NSTextView results in the unescaped output. I am guessing that is has to do with the settings on the NSTextView, but I do not see what changed to cause this. I am hoping someone can clue me into the probably dead obvious problem.
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please 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
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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