![]() In fact wstring_t and wchar_t (prefix L for litteral) are implementation dependant types, and since C++11, you also have char16_t and u16string (prefix u) that explicitely use UTF-16, or char32_t and u32string (prefix U) for full unicode support through UTF-32. The C++-ish way is to use char32_t based strings when full unicode support is required. That's the reason why most C++ implementation choosed that wchar_t basic IO would only process correctly BMP unicode characters for length to return a true number of characters. Std::wcout ::length would again be wrong if some of them are present in a wstring. ![]() Std::locale::global(locale("en_US.utf8")) ![]() Note that everything here is completely non-portable, there is just no portable way to input/output Unicode strings on the terminal. Note that you still need a font that contains the character you want to show (Lucida Console supports at least Greek and Cyrillic). Here is an example that shows four different methods, of which only the third (C conio) and the fourth (native Windows API) work (but only if stdin/stdout aren't redirected). How can I cin and cout some unicode text? ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |