I didn't find it in C++ standard saying that codecvt
s are compatible with mbtowc
s. And the C standard specifies mbtowc
as
If the function determines that the next multibyte character is complete and valid, it determines the value of the corresponding wide character and then, if pwc is not a null pointer, stores that value in the object pointed to by pwc.
But what does it mean by "value of the corresponding wide character"? Is it affected by locale? The definition of wide character says
wide character
value representable by an object of typewchar_t
, capable of representing any character in the current locale.
but later it "redefines" the "current locale" as an implementation-defined one.
The value of a wide character constant containing a single multibyte character that maps to a single member of the extended execution character set is the wide character corresponding to that multibyte character, as defined by the
mbtowc
,mbrtoc16
, ormbrtoc32
function as appropriate for its type, with an implementation-defined current locale.
As this answer says, wide-exec-charset
has nothing to do with C library function, but some C++ API such as filesystem::path
still take advantage of it.
Now I'm really confused, what is the encoding used by multibyte/wide character conversion functions? Is it locale dependent or implementation defined? Or even somehow the same as codecvt
s' UCS-2 or UTF-32?