lengthOfBytesUsingEncoding not correct
lengthOfBytesUsingEncoding not correct
- Subject: lengthOfBytesUsingEncoding not correct
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Fri, 15 Feb 2013 15:13:39 +0700
This program:
NSString *s = @"หัวหิน";
NSUInteger l3 = [ s lengthOfBytesUsingEncoding: NSUTF16StringEncoding ];
NSLog(@"%s NSUTF16StringEncoding length %lu", __FUNCTION__, l3);
NSData *d9 = [ s dataUsingEncoding: NSUTF16StringEncoding ];
NSLog(@"%s NSUTF16StringEncoding data %lu %@", __FUNCTION__, [d9 length], d9);
prints:
NSUTF16StringEncoding length 12
NSUTF16StringEncoding data 14 <fffe2b0e 310e270e 2b0e340e 190e>
Why is the number of bytes first 12, then 14?
(NSUTF16StringEncoding data has 2 leading byte order bytes - but why does lengthOfBytesUsingEncoding not take this into it's count?)
OS X 10.8.2, Xcode 4.6
Gerriet.
_______________________________________________
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