diff --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp --- a/libcxx/src/locale.cpp +++ b/libcxx/src/locale.cpp @@ -4541,7 +4541,6 @@ dest = out; return true; } -#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS static bool checked_string_to_char_convert(char& dest, const char* ptr, @@ -4553,7 +4552,6 @@ return true; } -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS // First convert the MBS into a wide char then attempt to narrow it using // wctob_l. wchar_t wout; @@ -4574,12 +4572,37 @@ default: return false; } -#else // _LIBCPP_HAS_NO_WIDE_CHARACTERS - return false; -#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_UNREACHABLE(); } +#else // _LIBCPP_HAS_NO_WIDE_CHARACTERS +static bool is_narrow_non_breaking_space(const char* ptr) { + // https://www.fileformat.info/info/unicode/char/202f/index.htm + return ptr[0] == '\xe2' && ptr[1] == '\x80' && ptr[2] == '\xaf'; +} +static bool is_non_breaking_space(const char* ptr) { + // https://www.fileformat.info/info/unicode/char/0a/index.htm + return ptr[0] == '\xc2' && ptr[1] == '\xa0'; +} + +static bool checked_string_to_char_convert(char& dest, const char* ptr, locale_t __loc) { + if (*ptr == '\0') + return false; + if (!ptr[1]) { + dest = *ptr; + return true; + } + + // FIXME: Work around specific multibyte sequences that we can reasonably + // translate into a different single byte. + if (is_narrow_non_breaking_space(ptr) || is_non_breaking_space(ptr)) { + dest = ' '; + return true; + } + + return false; +} +#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS // numpunct && numpunct diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp --- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp +++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp @@ -13,9 +13,6 @@ // XFAIL: LIBCXX-WINDOWS-FIXME -// TODO(mordante): Investigate these localization/format failures since updating the Docker image in CI -// UNSUPPORTED: stdlib=libc++ - // REQUIRES: locale.fr_FR.UTF-8 // diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp --- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp +++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp @@ -13,9 +13,6 @@ // XFAIL: LIBCXX-WINDOWS-FIXME -// TODO(mordante): Investigate these localization/format failures since updating the Docker image in CI -// UNSUPPORTED: stdlib=libc++ - // REQUIRES: locale.fr_FR.UTF-8 // diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp --- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp +++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp @@ -11,9 +11,6 @@ // XFAIL: LIBCXX-WINDOWS-FIXME -// TODO(mordante): Investigate these localization/format failures since updating the Docker image in CI -// UNSUPPORTED: stdlib=libc++ - // REQUIRES: locale.en_US.UTF-8 // REQUIRES: locale.fr_FR.UTF-8 // REQUIRES: locale.ru_RU.UTF-8 diff --git a/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp b/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp --- a/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp +++ b/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp @@ -11,9 +11,6 @@ // XFAIL: LIBCXX-WINDOWS-FIXME -// TODO(mordante): Investigate these localization/format failures since updating the Docker image in CI -// UNSUPPORTED: stdlib=libc++ - // REQUIRES: locale.en_US.UTF-8 // REQUIRES: locale.fr_FR.UTF-8