MCPcopy Create free account
hub / github.com/andreasfertig/programming-with-cpp20 / main

Function main

05.11-stdFmtLocale0/main.cpp:12–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10using namespace std::literals;
11
12int main()
13{
14 const double pi = 3.14;
15 const int i = 1'024;
16
17 // #A Create a German locale
18 const auto locDE = std::locale("de_DE.UTF-8"s);
19 // #B Create a US locale
20 const auto locUS = std::locale("en_US.UTF-8"s);
21
22 std::cout << "double with format(loc, ...)\n";
23 std::cout << std::format(locUS, "𝛑 in US: {:L}\n", pi);
24 std::cout << std::format(locDE, "𝛑 in DE: {:L}\n", pi);
25
26 std::cout << "\nint with format(loc, ...)\n";
27 std::cout << std::format(locUS, "1'024 in US: {:L}\n", i);
28 std::cout << std::format(locDE, "1'024 in DE: {:L}\n", i);
29
30 // #C Simulate a different system locale
31 std::locale::global(locUS);
32 std::cout
33 << "\nint with format(...) after setting global loc\n";
34 std::cout << std::format("1'024 in US: {:L}\n", i);
35}

Callers

nothing calls this directly

Calls 1

formatFunction · 0.50

Tested by

no test coverage detected