• 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: NSString to bit pattern
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString to bit pattern


  • Subject: Re: NSString to bit pattern
  • From: Robert Claeson <email@hidden>
  • Date: Fri, 8 May 2009 23:13:12 +0100


On 8 May 2009, at 23:00, Andrew Farmer wrote:

On 08 May 09, at 08:47, Greg Guerin wrote:
A string is a sequence of characters. Retrieve each character, determine its bit-pattern, then append that pattern to an NSMutableString. Now you have to figure out how to turn a character into its bit-pattern. So break that down.

One extra complication: By Cocoa's standards, a string is not a sequence of bytes: it's a sequence of Unicode codepoints.* To treat a string as a "bag of bytes", you will first need to choose a text encoding to treat the text as, then convert it using the NSString dataUsingEncoding: method.

The UTF encoding that will allow you to treat a string as bag of words (not bytes), where each Unicode codepoint takes exactly the same space, is UTF32.


UTF32 is also what C++ expects for its std::wstring type under Unix.

I have a framework for Unicode conversion and transformation that internally uses all UTF32 for ease of processing. It is unfortunately not open source at the present time.

Robert

_______________________________________________

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: NSString to bit pattern
      • From: Alastair Houghton <email@hidden>
References: 
 >Re: NSString to bit pattern (From: Greg Guerin <email@hidden>)
 >Re: NSString to bit pattern (From: Andrew Farmer <email@hidden>)

  • Prev by Date: Re: Converting NSString to C++ std::string
  • Next by Date: Re: [Q] Correct way to identify an application, Launch Services, & Spaces
  • Previous by thread: Re: NSString to bit pattern
  • Next by thread: Re: NSString to bit pattern
  • Index(es):
    • Date
    • Thread