Re: NSString to bit pattern
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