UTF-8 support - char or wchar_t?

Martin Sebor sebor@roguewave.com
Mon Jun 21 16:23:00 GMT 2004


Paolo Carlini wrote:

> Martin Sebor wrote:
> 
>> Paolo Carlini wrote:
>> ...
>>
>>> "codecvt<char, char, mbstate_t> implements a degenerate
>>>  conversion; it does not convert at all."
>>
>>
>> But not necessarily codecvt_byname<char, char, mbstate_t>, which
>> is presumably what the test case uses. I think the answer depends
>> on what the narrow internal encoding is in the fi_FI.UTF-8 locale.
>> If it's, say, ISO-8859-15 then there should be no reason to use
>> wchar_t.
> 
> 
> Indeed, thanks for the puntualization. However, if we expect the
> conversion to happen *automatically* during I/O, then fstream uses
> codecvt, not codecvt_byname.

I'm not sure I understand what you mean. fstream must use the
codecvt facet that's installed in the locale imbued in it. If
the fstream object is imbued with locale("fi_FI.UTF-8") it must
use codecvt_byname<char, char>. There isn't any codecvt<char,
char> in any named locale other than C or POSIX.

Martin



More information about the Libstdc++ mailing list