Re: String conversion help.
Re: String conversion help.
- Subject: Re: String conversion help.
- From: j o a r <email@hidden>
- Date: Thu, 23 Jun 2005 09:15:52 +0200
On 23 jun 2005, at 09.03, John Draper wrote:
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.
NSStringEncoding *strEncoding =
CFStringConvertEncodingToNSStringEncoding (kCFStringEncodingUTF16);
NSString *aStr = [[NSString alloc] initWithBytes: myStrData length:
myStrLen encoding: strEncoding];
Note that this encoding type was added with Mac OS X 10.4.
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.
const void *strBuf = [[aStr dataUsingEncoding: strEncoding] bytes];
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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