diff options
author | Takuji Tanaka <ttk@t-lab.opal.ne.jp> | 2020-12-11 13:01:21 +0000 |
---|---|---|
committer | Takuji Tanaka <ttk@t-lab.opal.ne.jp> | 2020-12-11 13:01:21 +0000 |
commit | 3bdcee46068093dea8aeff84697e9207eed0ced7 (patch) | |
tree | 8a0470aa3b7e187e33cc291eff94a7001583b615 /Build/source/texk | |
parent | 5bc564fc738e25da7a6053c4a255c3831735312d (diff) |
dvi2tty: Allow output of Unicode strings on console (Windows only)
git-svn-id: svn://tug.org/texlive/trunk@57112 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk')
-rw-r--r-- | Build/source/texk/dvi2tty/ChangeLog | 5 | ||||
-rw-r--r-- | Build/source/texk/dvi2tty/dvi2tty-src/dvistuff.c | 30 |
2 files changed, 30 insertions, 5 deletions
diff --git a/Build/source/texk/dvi2tty/ChangeLog b/Build/source/texk/dvi2tty/ChangeLog index 7d9e800d312..f8659346983 100644 --- a/Build/source/texk/dvi2tty/ChangeLog +++ b/Build/source/texk/dvi2tty/ChangeLog @@ -1,3 +1,8 @@ +2020-12-11 TANAKA Takuji <ttk@t-lab.opal.ne.jp> + + * dvistuff.c: Allow output of Unicode strings on Windows console. + It works with "-Eu -q" option. (Windows only) + 2017-03-27 Karl Berry <karl@freefriends.org> * Makefile.am (AM_TESTS_ENVIRONMENT): use instead of TESTS_ENVIRONMENT. diff --git a/Build/source/texk/dvi2tty/dvi2tty-src/dvistuff.c b/Build/source/texk/dvi2tty/dvi2tty-src/dvistuff.c index ec05239ef18..652da28531c 100644 --- a/Build/source/texk/dvi2tty/dvi2tty-src/dvistuff.c +++ b/Build/source/texk/dvi2tty/dvi2tty-src/dvistuff.c @@ -679,11 +679,31 @@ void printpage(void) if (ch >= SPACE || allchar) { if (utf8 && (ch & IS_UNICODE)) { - mbch = UCStoUTF8(ch & MAX_UNICODE); - if (BYTE1(mbch) != 0) putc((unsigned char)BYTE1(mbch), output); - if (BYTE2(mbch) != 0) putc((unsigned char)BYTE2(mbch), output); - if (BYTE3(mbch) != 0) putc((unsigned char)BYTE3(mbch), output); - /* always */ putc((unsigned char)BYTE4(mbch), output); +#ifdef WIN32 + wchar_t wch; + HANDLE hStdout; + DWORD ret; + const int fd = fileno(output); + + if ((fd == fileno(stdout) || fd == fileno(stderr)) && _isatty(fd)) { + if (fd == fileno(stdout)) + hStdout = GetStdHandle(STD_OUTPUT_HANDLE); + else + hStdout = GetStdHandle(STD_ERROR_HANDLE); + + wch=(wchar_t)(ch & MAX_UNICODE); /* do not expect over BMP */ + WriteConsoleW(hStdout, &wch, 1, &ret, NULL); + + } else { +#endif + mbch = UCStoUTF8(ch & MAX_UNICODE); + if (BYTE1(mbch) != 0) putc((unsigned char)BYTE1(mbch), output); + if (BYTE2(mbch) != 0) putc((unsigned char)BYTE2(mbch), output); + if (BYTE3(mbch) != 0) putc((unsigned char)BYTE3(mbch), output); + /* always */ putc((unsigned char)BYTE4(mbch), output); +#ifdef WIN32 + } +#endif } else if (japan) { for (k = 0; k < kanji1; k++) { |