Re: Converting wchar_t string to NSString
Re: Converting wchar_t string to NSString
- Subject: Re: Converting wchar_t string to NSString
- From: Glen Low <email@hidden>
- Date: Sun, 8 Feb 2004 13:32:26 +0800
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.
This is an educated guess, and I'm assuming your wchar_t string is
already in Unicode (as opposed to some other 2-byte encoding).
initWithCharacters: length: could be used with 1st param cast from your
wchar_t string. length = wcslen * 2.
initWithBytes: length: encoding: could be used with encoding =
NSUnicodeStringEncoding. length = wcslen * 2.
CFStringCreateWithBytes could be used with encoding =
CFStringEncodingUnicode. (CFStringRef is toll-free bridged with
NSString).
Cheers, Glen Low
---
pixelglow software | simply brilliant stuff
www.pixelglow.com
_______________________________________________
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.