Re: wstring
Re: wstring
- Subject: Re: wstring
- From: Kevin Hoyt <email@hidden>
- Date: Mon, 22 Mar 2004 08:34:55 -0800
Now you've got me curious...
Doesn't Mac OS X support the "C-UTF-8" locale?
If the locale is set to "C-UTF-8", what does it mean to do mbstowcs(),
thus converting a UTF-8 string to wchar_t?
The only way I know of to properly load up a wchar_t string is to use
mbstowcs(). Unless mbstowcs() converts UTF-8 into a specific codepage, it
must be a form of Unicode, we just don't know what that encoding is.
Is there any reason Apple can not say what encoding is used for wchar_t
strings? This information is sometimes useful, if for no other reason, so
we can talk about this with other people and not be ignorant :-)
Message: 10
From: Chris Espinosa <email@hidden>
Subject: Re: wstring
Date: Fri, 19 Mar 2004 12:35:28 -0800
To: XCode Forum <email@hidden>
On Mar 18, 2004, at 10:21 PM, Chris Ridd wrote:
>> We are using X-Platform code that uses std::wstring heavily.
>> As I understand these are 32 bit under the GCC.
>> We have to display those strings and therefore we need to convert
>> them.
>> How can we translate from 32 bit unicode into 16 bit unicode?
>> Are there other options?
>>
>> All help appreciated.
>> Bernard
>
> Wstrings are strings of wchar_t, which are 4 bytes wide on 10.3. I
> can't
> however see any definition of what each wchar_t actually contains, but
> they're probably UTF-32. Note that the contents of wchar_t is *very*
> implementation dependent. (Which might explain the documentation's
> reticence.)
>
> Apple has various converters in CoreFoundation and Foundation, but
> none of
> them (AFAICS) can cope with UTF-32. However doing so yourself is a
> simple
> matter of programming, and you should probably look at
> <URL:http://www.unicode.org/faq/utf_bom.html>. They've even got links
> to
> sample code.
wstring and wchar are not defined in terms of Unicode. They're just
"wide", not in any particular encoding. The documentation is reticent
because the C++ spec is.
If you choose to put Unicode of any stripe into a wchar_t, you do so at
your peril. Since you own the encoding, you own the problem of
transcoding.
Mac OS X has two excellent transcoding utilities:
1) CFString utilities. You can create a CFString given data in any
encoding and retrieve data in any other. Hundreds of encodings are
supported, and the API simply takes predefined constants. It only
understands UTF-8 and Unicode (UTF-16).
http://developer.apple.com/documentation/CoreFoundation/Reference/
CFStringRef/
2) Text Encoding Converter and Unicode Utilites have specific APIs for
doing encoding conversions, including specific UTF encodings
(kUnicode32BitFormat)
http://developer.apple.com/documentation/Carbon/Reference/
Text_Encodin_sion_Manager/index.html
3) GNU libconv is an open-source library toat does character
conversions, including UTF-32.
http://www.opensource.apple.com/darwinsource/7.0b1/libiconv/libiconv/
lib/converters.h
Chris
--__--__--
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.