From 0e45eaa243e0008ecc5a2e48d746d793a7cda314 Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Sat, 29 Jun 2013 13:55:27 +0000 Subject: Right console output on windows in ptex and uptex (from T. Tanaka). git-svn-id: svn://tug.org/texlive/trunk@31036 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/ptexenc/ChangeLog | 5 +++++ Build/source/texk/ptexenc/ptexenc.c | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Build/source/texk/ptexenc/ChangeLog b/Build/source/texk/ptexenc/ChangeLog index 86e6d5f6c80..41550559b74 100644 --- a/Build/source/texk/ptexenc/ChangeLog +++ b/Build/source/texk/ptexenc/ChangeLog @@ -1,3 +1,8 @@ +2013-06-29 Akira Kakuto + + * ptexenc.c: Provide right console output on windows for both + ptex and uptex if --sjis-terminal option is given. (from T. Tanaka). + 2013-06-25 Akira Kakuto * ptexenc.c: Remove redundant lines in input_line2(), which are diff --git a/Build/source/texk/ptexenc/ptexenc.c b/Build/source/texk/ptexenc/ptexenc.c index b492876c081..fa680201542 100644 --- a/Build/source/texk/ptexenc/ptexenc.c +++ b/Build/source/texk/ptexenc/ptexenc.c @@ -424,6 +424,7 @@ static int put_multibyte(long c, FILE *fp) { if ((fd == fileno(stdout) || fd == fileno(stderr)) && _isatty(fd)) { HANDLE hStdout; DWORD ret, wclen; + UINT cp; wchar_t buff[2]; char str[4]; int mblen; @@ -440,8 +441,13 @@ static int put_multibyte(long c, FILE *fp) { /* always */ str[mblen++]=BYTE4(c); #define CP_932 932 +#define CP_UTF8 65001 - if (MultiByteToWideChar(CP_932, 0, str, mblen, buff, 2) == 0) + if (is_internalUPTEX()) + cp = CP_UTF8; + else + cp = CP_932; + if (MultiByteToWideChar(cp, 0, str, mblen, buff, 2) == 0) return EOF; wclen = mblen > 3 ? 2 : 1; @@ -484,9 +490,12 @@ int putc2(int c, FILE *fp) #ifdef WIN32 if ((fp == stdout || fp == stderr) && (_isatty(fd) || !prior_file_enc)) { - if (sjisterminal) - output_enc = ENC_SJIS; - else + if (sjisterminal) { + if (is_internalUPTEX()) + output_enc = ENC_UTF8; + else + output_enc = ENC_SJIS; + } else #else if ((fp == stdout || fp == stderr) && !prior_file_enc) { #endif -- cgit v1.2.3