> first, a slightly pedantic but important observation: there is only
> *one* standard in force, the ISO / IEC Standard 14882: 2003, available
> in pdf from ISO or in printed form from Wiley: anything else, in
> particular online documents or manuals / books are certainly useful
> while learning and studying the C++ language but do not represent by
> themselves a standard in any sense.
>
> That said, in the area of locale vs streams, a lot is implementation
> defined: our implementation, by defaults has the predefined streams
> (cin, cout, wcin, wcout...) synced with stdio. That means that certainly
> the wchar_t versions are sensible to the global locale, because they use
> directly the underlying wchar_t C library functions to achieve that
> sync. You can change that behavior (thus loosing the sync) by calling
> sync_with_stdio(false) before any I / O.
>
> Paolo.
>
Thanks, for pointing that about the standard out :-) - you are right of cource!
Your answer mostly makes sence to me, but if wcout uses the C library
functions then locale:global(...) should affect it even when wcout is
used before setting the global locale. That does not happen! Here is
the code:
wcout << 1 << endl;
locale::global(locale("en_US.UTF-8"));
wcout << L"\xF8" << endl;
It wants to output a LATIN SMALL LETTER O WITH STROKE, but instead it
outputs '?'. If I remove the first line, it works.
As far as I can see, it should work in both cases if it was the locale
of the C library that was effectively used by wcout.
Do you have an explanation?
:-)
Kristian