[RFC] moneypunct<wchar_t>: mbsrtowcs or just btowc?

Paolo Carlini pcarlini@suse.de
Thu Apr 8 19:21:00 GMT 2004


Hi,

this one seems a little more subtle.

In moneypunct<wchar_t>::_M_initialize_moneypunct we construct positive_sign,
negative_sign and curr_symbol for wchar_t starting from langinfo calls.

The point is, no calls are available specific for wchar_t, therefore we 
resort
to /the very same/ calls used for plain chars:

    __nl_langinfo_l(__POSITIVE_SIGN, __cloc)
    __nl_langinfo_l(__NEGATIVE_SIGN, __cloc)
    __nl_langinfo_l(__CURRENCY_SYMBOL, __cloc)
    __nl_langinfo_l(__INT_CURR_SYMBOL, __cloc)

then, in order to arrive to wchar_t, we make use of mbsrtowcs.

However, if I'm not mistaken, this is "overkill", since those langinfo calls
return just plain "C" strings, not multibyte sequences! Therefore the simple
btowc (in a (very short) loop) would achieve the same result. We could also
avoid a lot of complexity (e.g., no __uselocale/setlocale, no memset)

If nobody finds soon a fault in my reasoning, I will go ahead and 
prepare and
test a complete patch (at my own risk ;) ...

Paolo.



More information about the Libstdc++ mailing list