Re: string encoding in NSMutableData
Re: string encoding in NSMutableData
- Subject: Re: string encoding in NSMutableData
- From: John Stiles <email@hidden>
- Date: Wed, 8 Aug 2007 13:32:15 -0700
On Aug 8, 2007, at 12:09 PM, Jaime Magiera wrote:
On Aug 8, 2007, at 1:04 PM, Alastair Houghton wrote:
On 8 Aug 2007, at 17:34, Paolo Manna wrote:
output = [NSMutableData dataWithBytes:[key
cStringUsingEncoding: NSUnicodeStringEncoding]
length:4];
}
Instead of what I expect, the result is...
a9006100
Which appears to be the string, but with lots of padding :)
Yes, Unicode in this context is synonym for UTF-16, i.e. 16 bits per
char:
It may seem minor, but UTF-16 is *not* 16-bits per character.
It's 16-bits per code unit. The difference matters with combining
characters and surrogate pairs. (There is also the issue of what
exactly you consider to be a character, which can be a little
involved for e.g. Indic scripts.)
Cool, thanks for the direction and clarification. That gives me a
good launching point.
I think going to NSString and NSData might be a little overkill given
that the actual type in question appears to just be an OSType (which
is just an int, nothing more). Why all the handstands here?
_______________________________________________
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