This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[RFC] moneypunct<wchar_t>: mbsrtowcs or just btowc?
- From: Paolo Carlini <pcarlini at suse dot de>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Cc: Benjamin Kosnik <bkoz at redhat dot com>
- Date: Thu, 08 Apr 2004 21:21:41 +0200
- Subject: [RFC] moneypunct<wchar_t>: mbsrtowcs or just btowc?
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.