• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
lengthOfBytesUsingEncoding not correct
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: lengthOfBytesUsingEncoding not correct
      • From: Markus Spoettl <email@hidden>
  • Prev by Date: Re: Recursive file copy with good progress data?
  • Next by Date: Re: lengthOfBytesUsingEncoding not correct
  • Previous by thread: Re: Recursive file copy with good progress data?
  • Next by thread: Re: lengthOfBytesUsingEncoding not correct
  • Index(es):
    • Date
    • Thread