Re: Simple C++ compiler test. How does yours fare?

From: Doug Schiffer (dschiffer@servtech.com)
Date: Mon Feb 03 1997 - 20:54:39 EST


Mark Leisher wrote:
>
> Doug> I coded a very simple test of the level of support for wide
> Doug> character strings in a C/C++ compiler. Unfortunately it > shows that
> Doug> there are still compilers out there that will have trouble > even at
> Doug> the entry level of Unicode functionality.
>
> Unfortunately, gcc and g++ seem to convert \x4e00 to 0, and nothing
> will print.

Correct, and there are a couple of possible explanations:

1) The compiler has wchar_t as 8 bits. 0x4e00 will have the high
   byte truncated, and will be reduced to 0. A zero byte is the C
   marker for end of string. So, the program will end immediately
   with no output.

2) wchar_t is 16 (or more) bits, but the compiler is taking the string
   as an 8 bit string and *then* promoting it to wchar_t. The high byte
   is lost in this arrangement, and it produces the exact same effect
   as problem 1.

To differentiate these 2 slightly different problems, I should have
included a test line as to the size of wchar_t. This line should
do the trick:

printf("This compiler has wchar_t as %d bytes (%sUnicode ready)\n",
        sizeof(wchar_t), (sizeof(wchar_t)>1)?"","*NOT* " );

I should have explained this feature of my simple test. Thanks for
making me explain it ! :-)



This archive was generated by hypermail 2.1.2 : Tue Jul 10 2001 - 17:20:33 EDT