Re: wstring
Re: wstring
- Subject: Re: wstring
- From: Chris Espinosa <email@hidden>
- Date: Fri, 19 Mar 2004 12:35:28 -0800
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.
References: | |
| >Re: wstring (From: Chris Ridd <email@hidden>) |