Topic: wchar_t question


Author: "Gil Shafriri" <gilsh@microsoft.com>
Date: 2000/06/25
Raw View
Hi,

Is the following statement  always correct  according to the c++ standard?
wchar_t('a') == L'a'

Thanks,

Gil


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: kanze@gabi-soft.de
Date: 2000/06/26
Raw View
"Gil Shafriri" <gilsh@microsoft.com> writes:

|>  Is the following statement always correct according to the c++
|>  standard?  wchar_t('a') =3D=3D L'a'

Should it be?  For historical reasons, wchar_t is an integral type (as
is char).  Conversions between integral types must preserve value
(supposing that the target type can hold the value).  This means
numerical value.  If an implementation uses EBCDIC for standard char,
and Unicode for wchar_t, it is guaranteed that this statement is
incorrect, since wchar_t('a') has the numeric value of EBCDIC 'a' (194,
I think), where as L'a' has the numeric value of Unicode 'a' (97).

--=20
James Kanze                               mailto:kanze@gabi-soft.de
Conseils en informatique orient=E9e objet/
                   Beratung in objektorientierter Datenverarbeitung
Ziegelh=FCttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]