• 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: How to convert UInt8 array to NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to convert UInt8 array to NSString


  • Subject: Re: How to convert UInt8 array to NSString
  • From: Jens Alfke <email@hidden>
  • Date: Tue, 6 May 2008 08:56:38 -0700


On 6 May '08, at 7:03 AM, Thomas Engelmeier wrote:

As the OP wants to create NSStrings with data created by his application I'm pretty sure he will not want the the Windows encoding - unless he parses text documents originating from Windows.

He didn't say where the data originates from, or what those APIs are that return the strings. If they're networking APIs, the data could very likely have originated on Windows.


Also, you missed my point about using CP1252 (WinLatin1). It's useful as a fallback for any unknown C strings because (a) it's a superset of ISO-Latin-1, which (b) has no gaps in it (as ISO does, from 0x80-0x9F), so decoding text into an NSString will never fail and return nil. (I've debugged several crashes that stemmed from nil NSStrings decoded from garbage strings.)

If the bytes come from MacOS text files he may want to use the MacRoman encoding, otherwise creating UTF8 and passing around NSStrings will be the way to go - especially in Europe where all that äöüñá goodies exist.

For the most part only old (pre-OS X) files would still be using MacRoman. Current Mac apps generally default to UTF-8.


—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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: How to convert UInt8 array to NSString
      • From: Ricky Sharp <email@hidden>
    • Re: How to convert UInt8 array to NSString
      • From: Aki Inoue <email@hidden>
References: 
 >How to convert UInt8 array to NSString (From: Marc Lohse <email@hidden>)
 >Re: How to convert UInt8 array to NSString (From: Jens Alfke <email@hidden>)
 >Re: How to convert UInt8 array to NSString (From: Thomas Engelmeier <email@hidden>)

  • Prev by Date: 'Raises For Not Applicable Keys' not enough to step exception raises?
  • Next by Date: Re: Blob Detection with Core Image
  • Previous by thread: Re: How to convert UInt8 array to NSString
  • Next by thread: Re: How to convert UInt8 array to NSString
  • Index(es):
    • Date
    • Thread