From 3ad5cec47eb6322da416a715f7ea960ca82b126e Mon Sep 17 00:00:00 2001 From: HanishKVC Date: Thu, 2 May 2024 07:59:48 +0530 Subject: [PATCH] SimpCfg:CheckStrings:MacOS, wstring and wcout Without using imbue, I couldnt get non-english wstrings to print on mac. Need to check on linux also. Also avoid the uint8_t typecasting, given that wchar isnt 8bit --- common/simpcfg.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/simpcfg.hpp b/common/simpcfg.hpp index f6e5b3317..429fb02a6 100644 --- a/common/simpcfg.hpp +++ b/common/simpcfg.hpp @@ -332,13 +332,15 @@ void check_strings() { } } + std::wcout.imbue(std::locale("en_US.UTF-8")); std::vector vWide = { L"123", L"1अ3" }; std::cout << "**** wstring **** " << vWide.size() << std::endl; for(auto sCur: vWide) { + std::wcout << sCur << std::endl; std::wcout << std::format(L"wstring: [{}] len[{}] size[{}]", sCur, sCur.length(), sCur.size()) << std::endl; int i = 0; for(auto c: sCur) { - std::wcout << std::format(L"wstring:{}:pos:{}:char:{}[0x{:x}]\n", sCur, i, c, (uint8_t)c); + std::wcout << std::format(L"wstring:{}:pos:{}:char:{}[0x{:x}]\n", sCur, i, c, c); i += 1; } }