This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Fix support for multibyte thousands_sep and decimal_point in moneypunct_byname and numpunct_byname.
ClosedPublic

Authored by EricWF on Sep 3 2016, 5:52 PM.

Details

Summary

The underlying C locales provide the thousands_sep and decimal_point as strings, possible with more than one character. We currently don't handle this case even for wchar_t.

This patch properly converts the mbs -> wide character for moneypunct_byname<wchar_t>. For the moneypunct_byname<char> case we attempt to narrow the WC and if that fails we also attempt to translate it to some reasonable value. For example we translate U00A0 (non-breaking space) into U0020 (regular space). If none of these conversions succeed then we simply allow the base class to provide a fallback value.

Diff Detail

Event Timeline

EricWF updated this revision to Diff 70276.Sep 3 2016, 5:52 PM
EricWF retitled this revision from to [libc++] Fix support for multibyte thousands_sep and decimal_point in moneypunct_byname.
EricWF updated this object.
EricWF added a reviewer: mclow.lists.
EricWF added a subscriber: cfe-commits.
EricWF updated this revision to Diff 70277.Sep 3 2016, 5:58 PM
EricWF updated this object.

Remove secondary locale fix.

Just a few drive-by nits. Thanks for the patch!

src/locale.cpp
5849–5851

Are the newly-added braces necessary?

test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp
113

s/belowe/below

test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
112–116

s/belowe/below/

EricWF updated this revision to Diff 70278.Sep 3 2016, 6:11 PM
EricWF marked 3 inline comments as done.

Address all inline comments.

EricWF updated this revision to Diff 70494.Sep 6 2016, 5:04 PM
EricWF retitled this revision from [libc++] Fix support for multibyte thousands_sep and decimal_point in moneypunct_byname to [libc++] Fix support for multibyte thousands_sep and decimal_point in moneypunct_byname and numpunct_byname..
EricWF updated this object.
vangyzen added inline comments.
src/locale.cpp
4339

While you're here, you might change char to wchar_t.

4348

Maybe fix the spelling of "localization".

EricWF updated this revision to Diff 81010.Dec 10 2016, 4:29 PM
EricWF marked 2 inline comments as done.

Address inline comments.

EricWF accepted this revision.Dec 10 2016, 4:30 PM
EricWF added a reviewer: EricWF.
This revision is now accepted and ready to land.Dec 10 2016, 4:30 PM
EricWF closed this revision.Dec 10 2016, 4:31 PM