/****************************************************************************** * This program formats characters and strings. * * Copyright © 2020 Richard Lesh. All rights reserved. *****************************************************************************/ #include #include #include #include #include #include std::locale utf8loc(std::locale(), new std::codecvt_utf8); using namespace std; static wchar_t const c1 = L'C'; static wstring const c2 = L"-"; static int const c3 = 51; static int const c4 = 80; static int const c5 = 0x4F; static wstring const s = L"Boba Fett"; int main(int argc, char **argv) { setlocale(LC_ALL, "en_US.UTF-8"); wcout.imbue(utf8loc); wcin.imbue(utf8loc); wcout << fmt::format(L"c1: {0:c}", c1) << endl; wcout << fmt::format(L"c2: {0:c}", int(c2[0])) << endl; wcout << fmt::format(L"c3: {0:c}", wchar_t(c3)) << endl; wcout << fmt::format(L"c4: {0:c}", wchar_t(c4)) << endl; wcout << fmt::format(L"c5: {0:c}", wchar_t(c5)) << endl; wcout << fmt::format(L"s: {0:s}", s) << endl; wcout << fmt::format(L"s: {0:.4s}", s) << endl; wcout << fmt::format(L"s: |{0:10.4s}|", s) << endl; wcout << fmt::format(L"s: |{0:>10.4s}|", s) << endl; wcout << fmt::format(L"s: |{0:^10.4s}|", s) << endl; return 0; }