File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed
tests/GH_005780_non_ascii_locales Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -271,6 +271,7 @@ tests\GH_005472_do_not_overlap
271271tests\GH_005546_containers_size_type_cast
272272tests\GH_005553_regex_character_translation
273273tests\GH_005768_pow_accuracy
274+ tests\GH_005780_non_ascii_locales
274275tests\LWG2381_num_get_floating_point
275276tests\LWG2510_tag_classes
276277tests\LWG2597_complex_branch_cut
Original file line number Diff line number Diff line change 1+ # Copyright (c) Microsoft Corporation.
2+ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+ RUNALL_INCLUDE ..\usual_matrix.lst
Original file line number Diff line number Diff line change 1+ // Copyright (c) Microsoft Corporation.
2+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+ #include < algorithm>
5+ #include < cassert>
6+ #include < clocale>
7+ #include < iomanip>
8+ #include < iostream>
9+ #include < string>
10+
11+ std::string set_locale (const std::string& locale_name) {
12+ const char * ret = std::setlocale (LC_ALL, locale_name.c_str ());
13+ assert (ret != nullptr );
14+ return ret;
15+ }
16+
17+ std::string query_locale () {
18+ const char * ret = std::setlocale (LC_ALL, nullptr );
19+ assert (ret != nullptr );
20+ return ret;
21+ }
22+
23+ void assert_string_non_ascii (const std::string& string) {
24+ const auto char_not_ascii = [](const char c) { return (c & 0x80 ) != 0 ; };
25+ assert (std::any_of (string.begin (), string.end (), char_not_ascii));
26+ }
27+
28+ void test_gh_5780 () {
29+ // https://learn.microsoft.com/en-us/cpp/c-runtime-library/language-strings#supported-language-strings
30+ std::string locale_name = set_locale (" norwegian-bokmal.437" );
31+ assert_string_non_ascii (locale_name);
32+
33+ std::cerr.imbue (std::locale::classic ());
34+ std::cerr << std::setprecision (2 ) << 0.1 << std::endl;
35+
36+ assert (query_locale () == locale_name);
37+ }
38+
39+ int main () {
40+ test_gh_5780 ();
41+ }
You can’t perform that action at this time.
0 commit comments