Re: string encoding in NSMutableData
Re: string encoding in NSMutableData
- Subject: Re: string encoding in NSMutableData
- From: Alastair Houghton <email@hidden>
- Date: Wed, 8 Aug 2007 18:04:50 +0100
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.)
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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