win,tty: pass through utf-16 surrogate pairs
On Windows allow utf-16 surrogate pars to pass through, which allows conhost on newer Windows versions and other terminal emulators to be able to render them. Fixes: https://github.com/libuv/libuv/issues/2909 PR-URL: https://github.com/libuv/libuv/pull/2971 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Jameson Nash <vtjnash@gmail.com>
This commit is contained in:
parent
8a782f1815
commit
aa4fcc49a2
@ -2122,13 +2122,6 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
|
||||
abort();
|
||||
}
|
||||
|
||||
/* We wouldn't mind emitting utf-16 surrogate pairs. Too bad, the windows
|
||||
* console doesn't really support UTF-16, so just emit the replacement
|
||||
* character. */
|
||||
if (utf8_codepoint > 0xffff) {
|
||||
utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER;
|
||||
}
|
||||
|
||||
if (utf8_codepoint == 0x0a || utf8_codepoint == 0x0d) {
|
||||
/* EOL conversion - emit \r\n when we see \n. */
|
||||
|
||||
@ -2155,6 +2148,12 @@ static int uv_tty_write_bufs(uv_tty_t* handle,
|
||||
ENSURE_BUFFER_SPACE(1);
|
||||
utf16_buf[utf16_buf_used++] = (WCHAR) utf8_codepoint;
|
||||
previous_eol = 0;
|
||||
} else {
|
||||
ENSURE_BUFFER_SPACE(2);
|
||||
utf8_codepoint -= 0x10000;
|
||||
utf16_buf[utf16_buf_used++] = (WCHAR) (utf8_codepoint / 0x400 + 0xD800);
|
||||
utf16_buf[utf16_buf_used++] = (WCHAR) (utf8_codepoint % 0x400 + 0xDC00);
|
||||
previous_eol = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user