#include #include #include #include #include #include std::locale utf8loc(std::locale(), new std::codecvt_utf8); using namespace std; int main(int argc, char **argv) { setlocale(LC_ALL, "en_US.UTF-8"); wcout.imbue(utf8loc); wcin.imbue(utf8loc); wstring const first = L"First"; wstring const middle = L"Middle"; wstring const lastname = L"Last"; wstring const left = L"Left"; wstring const center = L"Center"; wstring const right = L"Right"; wstring const favorite = L"kerfuffle"; long const i1 = 3261963; short const i2 = -42; double const fp1 = 3.1415926; double const fp2 = 2.99792458e9; double const fp3 = -1.234e-4; wstring s = fmt::format(L"{2}, {0} {1}", first, middle, lastname); wcout << s << endl; s = fmt::format(L"{0} {1} {2}", left, center, right); wcout << s << endl; s = fmt::format(L"Favorite number is {0}", i1); wcout << s << endl; s = fmt::format(L"Favorite FP is {0}", fp1); wcout << s << endl; wchar_t c = favorite[0]; wcout << fmt::format(L"Favorite c is {0:c}", c) << endl; wcout << fmt::format(L"Favorite 11c is |{0:11c}|", c) << endl; wcout << fmt::format(L"Favorite <11c is |{0:<11c}|", c) << endl; wcout << fmt::format(L"Favorite ^11c is |{0:^11c}|", c) << endl; wcout << fmt::format(L"Favorite >11c is |{0:>11c}|", c) << endl; wcout << fmt::format(L"Favorite .<11c is |{0:.<11c}|", c) << endl; wcout << fmt::format(L"Favorite _^11c is |{0:_^11c}|", c) << endl; wcout << fmt::format(L"Favorite >11c is |{0: >11c}|", c) << endl; c = 0x1F92F; wcout << fmt::format(L"Favorite emoji c is {0:c}", c) << endl; wcout << fmt::format(L"Favorite s is {0:s}", favorite) << endl; wcout << fmt::format(L"Favorite .2s is {0:.2s}", favorite) << endl; wcout << fmt::format(L"Favorite 11s is |{0:11s}|", favorite) << endl; wcout << fmt::format(L"Favorite 11.2s is |{0:11.2s}|", favorite) << endl; wcout << fmt::format(L"Favorite <11.2s is |{0:<11.2s}|", favorite) << endl; wcout << fmt::format(L"Favorite ^11.2s is |{0:^11.2s}|", favorite) << endl; wcout << fmt::format(L"Favorite >11.2s is |{0:>11.2s}|", favorite) << endl; wcout << fmt::format(L"Favorite .<11.2s is |{0:.<11.2s}|", favorite) << endl; wcout << fmt::format(L"Favorite *^11.2s is |{0:*^11.2s}|", favorite) << endl; wcout << fmt::format(L"Favorite ->11.2s is |{0:->11.2s}|", favorite) << endl; wcout << fmt::format(L"Favorite d is {0:d}", i1) << endl; wcout << fmt::format(L"Another d is {0:d}", i2) << endl; wcout << fmt::format(L"Favorite b is {0:b}", i1) << endl; wcout << fmt::format(L"Another B is {0:b}", i2) << endl; wcout << fmt::format(L"Favorite o is {0:o}", i1) << endl; wcout << fmt::format(L"Another o is {0:o}", i2) << endl; wcout << fmt::format(L"Favorite x is {0:x}", i1) << endl; wcout << fmt::format(L"Another X is {0:X}", i2) << endl; wcout << fmt::format(L"Favorite #b is {0:#b}", i1) << endl; wcout << fmt::format(L"Another #B is {0:#b}", i2) << endl; wcout << fmt::format(L"Favorite #o is {0:#o}", i1) << endl; wcout << fmt::format(L"Another #o is {0:#o}", i2) << endl; wcout << fmt::format(L"Favorite #x is {0:#x}", i1) << endl; wcout << fmt::format(L"Another #X is {0:#X}", i2) << endl; wcout << fmt::format(L"Favorite 11d is |{0:11d}|", i1) << endl; wcout << fmt::format(L"Favorite +11d is |{0:+11d}|", i1) << endl; wcout << fmt::format(L"Favorite 011d is |{0:011d}|", i1) << endl; wcout << fmt::format(L"Favorite 011x is |{0:011x}|", i1) << endl; wcout << fmt::format(L"Favorite #011x is |{0:#011x}|", i1) << endl; wcout << fmt::format(L"Favorite f is {0:f}", fp1) << endl; wcout << fmt::format(L"Another f is {0:f}", fp2) << endl; wcout << fmt::format(L"One more f is {0:f}", fp3) << endl; wcout << fmt::format(L"Favorite e is {0:e}", fp1) << endl; wcout << fmt::format(L"Another e is {0:e}", fp2) << endl; wcout << fmt::format(L"One more e is {0:e}", fp3) << endl; wcout << fmt::format(L"Favorite g is {0:g}", fp1) << endl; wcout << fmt::format(L"Another g is {0:g}", fp2) << endl; wcout << fmt::format(L"One more g is {0:g}", fp3) << endl; wcout << fmt::format(L"Favorite .2f is {0:.2f}", fp1) << endl; wcout << fmt::format(L"Another .2f is {0:.2f}", fp2) << endl; wcout << fmt::format(L"One more .2f is {0:.2f}", fp3) << endl; wcout << fmt::format(L"Favorite .2e is {0:.2e}", fp1) << endl; wcout << fmt::format(L"Another .2e is {0:.2e}", fp2) << endl; wcout << fmt::format(L"One more .2e is {0:.2e}", fp3) << endl; wcout << fmt::format(L"Favorite .2g is {0:.2g}", fp1) << endl; wcout << fmt::format(L"Another .2g is {0:.2g}", fp2) << endl; wcout << fmt::format(L"One more .2g is {0:.2g}", fp3) << endl; wcout << fmt::format(L"Favorite 15.2f is |{0:15.2f}|", fp1) << endl; wcout << fmt::format(L"Another 15.2e is |{0:15.2e}|", fp2) << endl; wcout << fmt::format(L"One more 15.2g is |{0:15.2g}|", fp3) << endl; return 0; }