std::wcout can't print out Arabic chars and some mathmatical symbols
C / C++ / MFC
1
Posts
1
Posters
0
Views
1
Watching
-
Recently I want to find a general solution for std::wcout so that it can print out all unicode strings. but, after poking around on google, i can't find useful. I'm stuck here, anybody can help me? _setmode(_fileno(stdout), _O_U16TEXT); won't work as expected. Here is my current code snippet:
auto previousMode = \_setmode(\_fileno(stdout), \_O\_U16TEXT); std::wifstream wifs; wifs.imbue(std::locale(wifs.getloc(), new std::codecvt\_utf16)); wifs.open(L"F:\\\\重要网址.txt", std::ios\_base::binary); std::wstring line; std::getline(wifs, line); wcout << line << endl; wifs.close(); wcout << endl; cout << "∦" << endl; std::wofstream wofs; wofs.imbue(std::locale(wifs.getloc(), new std::codecvt\_utf16)); wofs.open(L"F:\\\\iMoney.txt", std::ios\_base::binary | std::ios\_base::ate); wofs << line << endl; wofs.close(); //it's important to restore mode to previous, otherwise std::cout will cause crash \_setmode(\_fileno(stdout), previousMode);
and here is some symbols to test your slution before post here: ∀, ∁, ∂, ∅, ∰, ∵, ∺, ⊙, ⋾, ⋻, ⋱, ⋭, ⋣, ⋧ Arabic: لطيفة الطقس اليوم