Op 16 sep 2009, om 12:44 heeft Greg Guerin het volgende geschreven:

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.

I know. :-) Hence my post to the list...

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.

I think that is indeed what it is: 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.

I have been trying many combinations of encodings/decodings, but without the intended result. I do know what NSString wants, but that's not what I have. I have stringA as shown, and I have to somehow morph it into something usable. Basically I need NSString to interpret the characters a second time, but NSString seems to do all it can to keep it as is. Normally, that's indeed what I want, but not now...

Johan

---
http://www.johankool.nl/

KOOLISTOV - Software for Mac and iPhone
http://www.koolistov.net/




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to