#include <fcntl.h>
#include <io.h>
#include <stdio.h>
int main(void) {
_setmode(_fileno(stdout), _O_U16TEXT);
wprintf(L"\x043a\x043e\x0448\x043a\x0430 \x65e5\x672c\x56fd\n");
return 0;
}
returns error at compilation: _O_U16TEXT was not declared in this scope
Is this a show-stopper with this compiler ?
Well, there's a simple workaround: just use values of these constants instead of their names. For example, _O_U16TEXT
is 0x00020000
and _O_U8TEXT
is 0x00040000
.
I've just confirmed that it works with _setmode
using g++ 4.8.1 on Windows 10:
#include <iostream>
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
int main() {
_setmode(_fileno(stdout), 0x00020000); // _O_U16TEXT
std::wcout << L"Русский текст\n";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With