Johan Kool wrote:

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.

Obvious answer: write your own parser. You know what the input is: octal-escaped ASCII. You know what the output is: bytes. After that, NSString can handle it.

This doesn't seem like a massively difficult problem to me. I wouldn't be surprised if you've spent more time doing experiments with encodings and decodings than if you'd just written a simple basic parser. There is a point at which avoiding work takes more work than doing the work.


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...


Actually, you only need to interpret the original characters once, to convert them to bytes. At that point you have UTF8 bytes, if your example stringA is correct, and NSString can handle that.

Personally, I would do the initial parsing of octal-escaped ASCII into an NSMutableData container for the bytes, then pass that to NSString along with the UTF8 encoding-identifier.

  -- GG

_______________________________________________

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