Re: NSString vs. encoding
Re: NSString vs. encoding
- Subject: Re: NSString vs. encoding
- From: Greg Guerin <email@hidden>
- Date: Wed, 16 Sep 2009 13:35:27 -0700
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 (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