Debug Assestion failure when using _setmode(_fileno(stdout), _O_U16TEXT);

Ioann 61 Reputation points
2022-01-25T10:41:30.52+00:00

I want to enable console to print Unicode Characters so i used _setmode(_fileno(stdout), _O_U16TEXT);
But once i do that an exception is thrown where this function is:
SetWindowsHookExW(WH_KEYBOARD_LL, hookproc_keyboard, NULL, 0);

"Unhandled exception at 0x00007FFEB1641208 (ucrtbase.dll) in testprogram.exe:
An invalid parameter was passed to a function that considers invalid parameters fatal."

and a window pops up showing this

"File: minkernel\crts\ucrt\src\appcrt\stdio\fputc.cpp
Line: 49

Expression: ( (_Stream.is_string_backed()) || (fn = _fileno(_Stream.public_stream()), ((_textmode_safe(fn) == __crt_lowio_text_mode::ansi) && !_tm_unicode_safe(fn))))

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts."

Can someone explain to me what this error is ?
Thanks in advance

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,431 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,546 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
948 questions
{count} votes