• 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
Re: NSUnicodeStringEncoding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSUnicodeStringEncoding


  • Subject: Re: NSUnicodeStringEncoding
  • From: Kyle Sluder <email@hidden>
  • Date: Fri, 11 Feb 2011 11:10:33 -0800

On Fri, Feb 11, 2011 at 10:57 AM, Todd Heberlein <email@hidden> wrote:
> Looking at the NSString class there is the method
>
>        initWithBytes:length:encoding:
>
> I have a unicode string (in C++ object) that I can extract in a number of different byte stream formats (UTF-8, UTF-16 (w or w/o BOM)) that I need to encode into an NSString. Does the NSUnicodeStringEncoding refer to UTF-8 encoding?

No. See the NSStringEncoding documentation:
http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/Reference/NSString.html#//apple_ref/doc/uid/20000154-BAJJAICE

NSUnicodeStringEncoding is an alias for NSUTF16StringEncoding. You're
best off getting UTF16 from your C++ string and explicitly using the
NSUTF16StringEncoding constant when creating your NSString. Since
UTF16 is the canonical representation of strings, this will result in
the fewest conversions, and using the explicit UTF16 constant rather
than the equivalent NSUnicodeStringEncoding will make your code
clearer.

--Kyle Sluder
_______________________________________________

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: NSUnicodeStringEncoding
      • From: Todd Heberlein <email@hidden>
References: 
 >NSUnicodeStringEncoding (From: Todd Heberlein <email@hidden>)

  • Prev by Date: NSUnicodeStringEncoding
  • Next by Date: Re: Performing the selector from a stored IMP
  • Previous by thread: NSUnicodeStringEncoding
  • Next by thread: Re: NSUnicodeStringEncoding
  • Index(es):
    • Date
    • Thread