texlive[57112] Build/source/texk/dvi2tty: dvi2tty: Allow output of
commits+takuji at tug.org
commits+takuji at tug.org
Fri Dec 11 14:01:21 CET 2020
Revision: 57112
http://tug.org/svn/texlive?view=revision&revision=57112
Author: takuji
Date: 2020-12-11 14:01:21 +0100 (Fri, 11 Dec 2020)
Log Message:
-----------
dvi2tty: Allow output of Unicode strings on console (Windows only)
Modified Paths:
--------------
trunk/Build/source/texk/dvi2tty/ChangeLog
trunk/Build/source/texk/dvi2tty/dvi2tty-src/dvistuff.c
Modified: trunk/Build/source/texk/dvi2tty/ChangeLog
===================================================================
--- trunk/Build/source/texk/dvi2tty/ChangeLog 2020-12-11 00:53:54 UTC (rev 57111)
+++ trunk/Build/source/texk/dvi2tty/ChangeLog 2020-12-11 13:01:21 UTC (rev 57112)
@@ -1,3 +1,8 @@
+2020-12-11 TANAKA Takuji <ttk at 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 at freefriends.org>
* Makefile.am (AM_TESTS_ENVIRONMENT): use instead of TESTS_ENVIRONMENT.
Modified: trunk/Build/source/texk/dvi2tty/dvi2tty-src/dvistuff.c
===================================================================
--- trunk/Build/source/texk/dvi2tty/dvi2tty-src/dvistuff.c 2020-12-11 00:53:54 UTC (rev 57111)
+++ trunk/Build/source/texk/dvi2tty/dvi2tty-src/dvistuff.c 2020-12-11 13:01:21 UTC (rev 57112)
@@ -679,11 +679,31 @@
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++) {
More information about the tex-live-commits
mailing list.