String conversion help.
String conversion help.
- Subject: String conversion help.
- From: John Draper <email@hidden>
- Date: Thu, 23 Jun 2005 00:03:57 -0700
Hi,
I have a string containing 16 bit characters. They are called UTF16 type
strings.
I know that NSString has "stringWithUTF8String" class methods, but
I don't see any class methods that can construct a NSString, given
a pointer to a buffer of characters of 16 bits in length (u_shorts)
or what I believe to be UTF16 type string encodings.
Can someone point me to the best way of constructing a NSString
from memory that might look like this:
"abc" is stored as:
{ 0x00, 0x61, 0x00, 0x62, 0x00, 0x63 } (Big Endian byte order)
And I want to use this as input in creating an NSString = @"abc".
I hope I explained this right.
I also want to be able to go the other way... IE: Given an NSString,
and a pointer to a buffer big enough to hold it, return the data in
UTF16 encoding in the buffer. Obviously, the buffer allocated would have
to be twice the size of the string plus 2 more bytes for the NULL at
the end.
The only encodings I see supported on the mac are:
NSASCIIStringEncoding
NSNEXTSTEPStringEncoding
NSUnicodeStringEncoding
NSISOLatin1StringEncoding
NSISOLatin2StringEncoding
NSSymbolStringEncoding
I have NO CLUE which of these is similar to UTF16 encodings? I tried
"NSUnicodeStringEncoding" and that seemed to be the most likely one,
but BOY was I wrong. I sure can use some tips here.
John
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden