Converting wchar_t string to NSString
Converting wchar_t string to NSString
- Subject: Converting wchar_t string to NSString
- From: David Elliott <email@hidden>
- Date: Sat, 7 Feb 2004 22:45:47 -0500
On Feb 5, 2004, at 2:30 PM, John Stiles wrote:
On Feb 5, 2004, at 9:17 AM, Darrin Cardani wrote:
At 2:02 AM -0800 2/5/04, email@hidden wrote:
How to convert C-string that contains japanese character to NSString?
Check out Carbon's text encoding converter. If the string is in a
Japanese Mac encoding, you can create a Mac to Unicode converter and
pass it the string. You can then put the Unicode bytes you get back
into an NSString with
NSString* newString = [ NSString stringWithCharacters:macStr
length:numBytes ];
That's an awful lot of work. You can use NSString's
initWithBytes:length:encoding:
[snip]
And it allows you to pass in the encoding of your string. A list of
valid NSStringEncodings is at:
[snip]
As a followup to this, does anybody know how to convert a string in
32-bit unicode into NSString? Right now I took the easy way out.
wxWindows can convert from wchar_t (used internally in its "unicode"
mode) to/from UTF-8 and NSString can do the same.
What's the best way to go straight from a wchar_t string to an
NSString? Keep in mind it would be helpful if this worked on OS < 10.3
because we may decide to implement our on wide-character C library
functions so that wxCocoa can be compiled and run in unicode mode on
any version of OS X.
-Dave
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.