Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std.os.windows: Support UTF-8 ↔ UTF-16 conversion for Windows native console I/O #16618

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/std/os.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,10 @@ pub const WriteError = error{

/// Connection reset by peer.
ConnectionResetByPeer,

/// This error occurs when trying to write UTF-8 text to a Windows console,
/// and the UTF-8 to UTF-16 conversion fails. Windows-only.
InvalidUtf8,
} || UnexpectedError;

/// Write to a file descriptor.
Expand Down Expand Up @@ -3239,8 +3243,7 @@ pub fn isatty(handle: fd_t) bool {
if (isCygwinPty(handle))
return true;

var out: windows.DWORD = undefined;
return windows.kernel32.GetConsoleMode(handle, &out) != 0;
return windows.IsConsoleHandle(handle);
}
if (builtin.link_libc) {
return system.isatty(handle) != 0;
Expand Down
Loading