UTF-16 console support for Windows#15051
Conversation
src/liblibc/lib.rs
Outdated
There was a problem hiding this comment.
We're trying to keep things out of liblibc nowadays, could you add these to c_win32.rs instead?
|
It would be nice to update libuv at the same time. If you open a PR against the |
src/libnative/io/mod.rs
Outdated
There was a problem hiding this comment.
If this is a windows-specific implementation, it should probably use the windows-specific function GetConsoleMode
There was a problem hiding this comment.
GetConsoleMode merely tells us the set of flags that we've set for the console, not whether it is or isn't a TTY. isatty does the job fine at telling whether we're attached to a TTY or just redirected to a file.
There was a problem hiding this comment.
It looks like it suffices for libuv, and I tend to not trust posix functions with file descriptors on windows, but if it's working well I guess it's working well.
|
No, setting the code page to UTF-8 does not work. I have already tested that option extensively in C++. The Windows console only supports narrow byte encodings and UTF-16. |
|
Ah, so output with UTF-8 does indeed work, but I've used both |
|
Even still, when using UTF-8, Windows will often act buggy. For some examples: It is probably safer to simply use UTF-16 because that is what Windows is built around. |
|
Added another commit to take into account comments by @alexcrichton |
src/libnative/io/mod.rs
Outdated
There was a problem hiding this comment.
This should not happen here. It's the responsibility of the caller to fall back to a file descriptor. This should have the same error path as the unix equivalent.
|
Oh dear, sorry for being so late to this! Feel free to ping a PR whenever you update this because sadly github doesn't send out notifications when that happens. |
This implementation does have the minor issue of not handling things correctly when a codepoint is split across multiple writes or reads, but its better than not having unicode support at all.
Adds a Windows specific struct
WindowsTTYinlibnativeand maketty_opencreate that struct on Windows. Adds needed functions and constants toc_win32.rs.Libuv still needs to be updated before #15028 can be closed.