Skip to content

Commit fffbb92

Browse files
committed
std.os.windows: Support UTF-8 ↔ UTF-16 conversion for Windows native console I/O
1 parent f887b02 commit fffbb92

File tree

4 files changed

+360
-13
lines changed

4 files changed

+360
-13
lines changed

lib/std/os.zig

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,10 @@ pub const WriteError = error{
10621062

10631063
/// Connection reset by peer.
10641064
ConnectionResetByPeer,
1065+
1066+
/// This error occurs when trying to write UTF-8 text to a Windows console,
1067+
/// and the UTF-8 to UTF-16 conversion fails. Windows-only.
1068+
InvalidUtf8,
10651069
} || UnexpectedError;
10661070

10671071
/// Write to a file descriptor.
@@ -3181,8 +3185,7 @@ pub fn isatty(handle: fd_t) bool {
31813185
if (isCygwinPty(handle))
31823186
return true;
31833187

3184-
var out: windows.DWORD = undefined;
3185-
return windows.kernel32.GetConsoleMode(handle, &out) != 0;
3188+
return windows.IsConsoleHandle(handle);
31863189
}
31873190
if (builtin.link_libc) {
31883191
return system.isatty(handle) != 0;

0 commit comments

Comments
 (0)