If you getting a error message with following pop-up in Visual Studio solution for C++ when using SetConsoleOutputCP(CP_UTF8) or _setmode(_fileno(stdin), _O_U8TEXT).
When debugging the following code, it will give you the above error.
Solution : Change this line of code wcout for all your statements to stdout.
--------------------------- Microsoft Visual C++ Debug Library --------------------------- Debug Assertion Failed! Expression: ( (_Stream->_flag & _IOSTRG) ||
( fn = _fileno(_Stream), ( (_textmode_safe(fn) == __IOINFO_TM_ANSI)
&& !_tm_unicode_safe(fn)))) For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.
When debugging the following code, it will give you the above error.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | int main(int argc, char* argv[]) { //https://alfps.wordpress.com/2011/12/08/unicode-part-2-utf-8-stream-mode/ // Set console code page to UTF-8 so console known how to interpret string data SetConsoleOutputCP(CP_UTF8); // Enable buffering to prevent VS from chopping up UTF-8 byte sequences setvbuf(stdout, nullptr, _IOFBF, LINESIZE); std::cout << "Latin Capital Letter O with Diaeresis Ö "; return EXIT_SUCCESS; } |
Solution : Change this line of code wcout for all your statements to stdout.
std::wcout << "Latin Capital Letter O with Diaeresis Ö ";
No comments:
Post a Comment