Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Unicode and wchar: (4 Items)
   
Unicode and wchar  
My QNX Version is 6.4.0.
I used unicode-16 and character code. And want to use wide-character functions such as "swprintf()","fgetws()" and so on
.
But the problem is that the "wchar_t" type is defined as "_Uint32t", but the unicode is 16bit width.

How should I deal with it?
Re: Unicode and wchar  
The answer is to use wchar_t. You will need to convert your 16bit values into wchar_t. Or, when you load your 16 bit 
strings -- load them directly into wchar_t and keep it this way.
Re: Unicode and wchar  
On Fri, 2010-02-26 at 02:29 -0500, Johnson Gu wrote:
> My QNX Version is 6.4.0.
> I used unicode-16 and character code. And want to use wide-character functions such as "swprintf()","fgetws()" and so 
on.
> But the problem is that the "wchar_t" type is defined as "_Uint32t", but the unicode is 16bit width.
> 
> How should I deal with it?

Note that C99 (and C90+Am1) wide characters are not, in general, the
same thing as Unicode code points (which are 21 bits wide; the UCS-2 and
UTF-16 encodings, for example, are 16 bits wide).  The ISO9899 standard
does not actually require any particular encoding (and, worse still,
doesn't require wchar_t to be any wider than char).

The QNX toolchain (which is essentially the GNU toolchain) and runtime
libraries (the wide char portions of which are essentially a licensed
version of Dinkumware) supports use of both multi-byte and wide
encodings.  The default for the wide character encoding is UTF-32/UCS-4.
(In principle you could change that using -fshort-wchar and/or
-fwide-exec-charset, but in practice it would be quite... tricky.  And
untested.  'nuff said.)

Note that depending on how much Unicode manipulation you intend to do,
libraries like iconv and icu may be helpful as well.

Regards,
Neil
Re: Unicode and wchar  
Got it.
Thank you!