Re: Converting wchar_t string to NSString
Re: Converting wchar_t string to NSString
- Subject: Re: Converting wchar_t string to NSString
- From: David Elliott <email@hidden>
- Date: Sun, 8 Feb 2004 12:06:46 -0500
On Feb 8, 2004, at 8:19 AM, Andrew Thompson wrote:
Indeed, the first question I'd attempt to answer is "what encoding is
my wchar_t" string in?
Scroll down to point 13 on this page for a good explanation of the
difference between a character set & a character encoding:
http://www.cafeconleche.org/books/effectivexml/chapters/00.html
Essentially your wchar_t is in the Unicode Character Set, but which
Encoding? If its truly a 4 byte encoding, the most likely candidates
are UTF-32 or UCS-4. Once you know the answer to this, you should be
able to use one of the functions Glen mentions.
No, I do know the difference between encoding and character set. I
thought it was clear from my message that I was using the wchar_t type
(from Panther and Jaguar) and wcs* functions from Panther using a
4-byte (that is what wchar_t is on OS X after all) Unicode character
set. Irrelevant to this discussion but worth noting is that at some
point we intend to provide our own implementations of wcs* functions so
that apps will run on Jaguar and presumably Puma as well. A wchar_t
string in wxWindows is most certainly in the Unicode character set, now
whether it is using UTF-32 or UCS-4 encoding I am unsure, supporting
both would be nice. I will say it's using the wcs* functions to do all
the work so whatever encoding the wcs* functions are using is what it's
using.
The problem is in all those encodings listed on Apple's page I didn't
see even one that took 4-byte unicode characters in any encoding. Did
I just miss it? I've visited those pages quite a few times.
Alternatively, I recently found out wxWindows has functions for
converting to/from UTF-16 so if NSString can efficiently take that
(i.e. without doing another conversion itself) then that would be an
option. Right now I'm doing a conversion from wxString (which is using
4-byte wchar_t based strings) to UTF-8 and then to NSString. That
involves two conversions when one would be better.
-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.