Re: NSString vs. encoding
Re: NSString vs. encoding
- Subject: Re: NSString vs. encoding
- From: Greg Guerin <email@hidden>
- Date: Wed, 16 Sep 2009 12:44:53 -0700
Johan Kool wrote:
NSString *stringA = @"J\\303\\270ha\\314\\212n\\040i\\314\\210s\
\040Li\ \314\\200e\\314\\201\\306\\222";
NSLog(@"stringA %@ (expected Jøhån ïs Lìéƒ)", stringA);
You're doing it wrong. NSNonLossyASCIIStringEncoding expects one
escaped unit per Unicode code-point. It doesn't parse "multi-byte"
forms like "\\303\\270", which I assume is intended to be something
like an octal-escaped UTF8 encoding.
To get a sense for what it wants as input, I recommend that you
create a test with some hard-wired strings, then convert to bytes
using the NSNonLossyASCIIStringEncoding, and dump the resulting ASCII
text. Or you could use TextEdit.app and save or open as non-lossy
ASCII.
-- GG
_______________________________________________
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