Re: NSString and wchar_t
Re: NSString and wchar_t
- Subject: Re: NSString and wchar_t
- From: Sandy Martel <email@hidden>
- Date: Tue, 18 Dec 2001 11:12:04 -0500
On Tuesday, December 18, 2001, at 10:08 AM, James Gregurich wrote:
What is the proper way to convert between wchar_t* and
NSString/NSMutableString in Objective C++?
wchar_t is a unicode (double byte) character
no, wchar_t is four bytes with gcc...
To illustrate what I am after:
wchar_t *x = L"This is a string";
It seems that there is no way to get a wchar_t string in a CFString, I
suppose its the same for a NSString.
If you know that the string just contain UTF16 data, you can strip the
extra 2 bytes by copying it in a buffer of UInt16 and then call
myString = [NSString initWith
Data:dataBuffer
encoding:NSUnicodeStringEncoding];
but if the string really contains UTF32 data, all I can see is use the
Carbon TextConverter API to get the string in UTF16 encoding and then
call the initWith
Data:encoding:.
If someone know a better way...let me know please
Sandy.