On Sat, 23 Feb 2008 23:19:57 +0200, Ioannis Vranos
<iv*****@nospam .no.spamfreemai l.grwrote:
Alf P. Steinbach wrote:
[...]
>Ans as has also been remarked else-thread, by Boris, one issue,
relevant for i/o, is that the wide character streams convert to and
from narrow characters. wcout converts to narrow characters, and wcin
converts from narrow characters. They're not wide character streams,
they're wide character converters.
I am not sure I understand this.
Isn't L"some text" a wide character string literal? Don't wcout, wcin
and wstring provide operator<< and operator>overlo ads for wide
characters and wide character strings?
wcout and wcin represent external devices. When you read from or write to
external devices the facet codecvt is used. The C++ standard says there
are only two: codecvt<char, char, mbstate_twhich doesn't do anything and
codecvt<wchar_t , char, mbstate_twhich converts from wchar_t to char. As
you see there is an implicit conversion to char even if you actually use
wchar_t in your program. You don't know either how the conversion of
codecvt<wchar_t , char, mbstate_tworks (there is no guarantee that it's
UTF-16 to UTF-8 for example). Either you convert to UTF-8 explicitly and
write to cout or you define or use a codecvt from a third-party library
(like
http://www.boost.org/libs/serializat.../codecvt.html).
Boris
[...]