Here are some excerpts from my copy of the 2014 draft standard N4140
22.5 Standard code conversion facets [locale.stdcvt]
3 F
Both your interpretations are incorrect. The standard doesn't require that there be a single wchar_t
encoding, just like it doesn't require a single char
encoding. The codecvt_utf8
facet must convert between UTF-8 and UCS-2 or UCS-4.
This true even UTF-8, UCS-2, and UCS-4 are not supported as character sets in any locale.
If Elem
is of type wchar_t
and isn't big enough to store a UCS-2 value than then the conversion operations of the codecvt_utf8
facet are undefined because the standard doesn't say what happens in that case. If it is big enough (or if you want to argue that the standard requires that it must be big enough) then it's merely implementation defined whether the UCS-2 or UCS-4 wchar_t
values the facet generates or consumes are in an encoding compatible with any locale defined wchar_t
encoding.