summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Build/source/texk/ptexenc/ChangeLog5
-rw-r--r--Build/source/texk/ptexenc/ptexenc.c17
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 <kakuto@fuk.kindai.ac.jp>
+
+ * 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 <kakuto@fuk.kindai.ac.jp>
* 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