
29 Oct
2011
29 Oct
'11
4:23 p.m.
On Saturday, 29 October 2011, Peter Dimov wrote:
The "dir" command has no problem displaying arbitrary file names directly to the console (presumably via WriteConsoleW), but once it has to write to a file, it needs to convert to narrow and no code page other than 65001 can express the above file name.
This is not that relevant to the wider issue, but wide streams will work for console output if you first do this: if (_isatty(_fileno(stdout))) _setmode(_fileno(stdout), _O_U16TEXT); if (_isatty(_fileno(stderr))) _setmode(_fileno(stderr), _O_U16TEXT); i.e. set the output mode to UTF-16 when writing to the console. This only works for recent versions of Visual C++. Obviously doesn't fix piped output.