[PATCH] codecvt<wchar_t, char, mbstate_t> support for UTF-8
Pétur Runólfsson
peturr02@ru.is
Mon Jan 27 19:23:00 GMT 2003
Benjamin Kosnik wrote:
> >You are of course right that MB_CUR_MAX is not thread-safe in general
> >(since it depends on the global locale set by setlocale).
> This however
> >seems to be a general problem with the generic locale implementation
> >(including codecvt<wchar_t, char, mbstate_t>::do_in and do_out).
>
> This is also correct.
Well, actually the use of MB_CUR_MAX in do_encoding is not thread-unsafe
per se, it is simply unsafe :-) One usage for MB_CUR_MAX is to calculate
buffer sizes for do_out, if setlocale is called between do_encoding and
do_out, the buffer size may be wrong. It doesn't matter if setlocale is
called from the same thread or from a different one.
Regards,
Petur
More information about the Libstdc++
mailing list