diff options
author | Takuji Tanaka <KXD02663@nifty.ne.jp> | 2014-01-17 14:08:10 +0000 |
---|---|---|
committer | Takuji Tanaka <KXD02663@nifty.ne.jp> | 2014-01-17 14:08:10 +0000 |
commit | 7d29db1bbb8a9d2234d40aa381c0be0e848b4c9a (patch) | |
tree | 35ccf9a9855a909ee1e420839d9b05d76a663ea5 /Build/source | |
parent | 0bcccfa9db2c63b268dfc9099babdbdfcd085155 (diff) |
xetex [WIN32]: Accept Unicode characters from STDIN on console
git-svn-id: svn://tug.org/texlive/trunk@32700 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r-- | Build/source/texk/web2c/xetexdir/ChangeLog | 5 | ||||
-rw-r--r-- | Build/source/texk/web2c/xetexdir/XeTeX_ext.c | 37 | ||||
-rw-r--r-- | Build/source/texk/web2c/xetexdir/xetex.h | 3 |
3 files changed, 45 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/xetexdir/ChangeLog b/Build/source/texk/web2c/xetexdir/ChangeLog index 9fdda910854..a0a9961bc16 100644 --- a/Build/source/texk/web2c/xetexdir/ChangeLog +++ b/Build/source/texk/web2c/xetexdir/ChangeLog @@ -1,3 +1,8 @@ +2014-01-17 TANAKA Takuji <KXD02663@nifty.ne.jp> + + * XeTeX_ext.c, xetex.h: Accept Unicode characters from STDIO + on console. (Windows only) + 2013-12-06 Akira Kakuto <kakuto@fuk.kindai.ac.jp> * XeTeX_ext.c: Remove unused variables. diff --git a/Build/source/texk/web2c/xetexdir/XeTeX_ext.c b/Build/source/texk/web2c/xetexdir/XeTeX_ext.c index 0d83b07aca7..afbce0bd4f1 100644 --- a/Build/source/texk/web2c/xetexdir/XeTeX_ext.c +++ b/Build/source/texk/web2c/xetexdir/XeTeX_ext.c @@ -325,6 +325,12 @@ static char* byteBuffer = NULL; static uint32_t *utf32Buf = NULL; int i, tmpLen; int norm = getinputnormalizationstate(); +#ifdef WIN32 + const int fd = fileno(f->f); + if (fd == _fileno(stdin) && _isatty(fd)) { + f->encodingMode = WIN32CONSOLE; + } +#endif last = first; @@ -2779,6 +2785,11 @@ get_uni_c(UFILE* f) { int rval; int c; +#ifdef WIN32 + HANDLE hStdin; + DWORD ret; + wint_t wc[1]; +#endif if (f->savedChar != -1) { rval = f->savedChar; @@ -2854,6 +2865,32 @@ get_uni_c(UFILE* f) } break; +#ifdef WIN32 + case WIN32CONSOLE: + hStdin = GetStdHandle(STD_INPUT_HANDLE); + if (ReadConsoleW(hStdin, wc, 1, &ret, NULL) == 0) { + rval = EOF; + break; + } + rval = wc[0]; + if (rval >= 0xd800 && rval <= 0xdbff) { + int lo; + if (ReadConsoleW(hStdin, wc, 1, &ret, NULL) == 0) { + rval = EOF; + break; + } + lo = wc[0]; + if (lo >= 0xdc00 && lo <= 0xdfff) + rval = 0x10000 + (rval - 0xd800) * 0x400 + (lo - 0xdc00); + else { + rval = 0xfffd; + f->savedChar = lo; + } + } else if (rval >= 0xdc00 && rval <= 0xdfff) + rval = 0xfffd; + break; +#endif + case RAW: rval = getc(f->f); break; diff --git a/Build/source/texk/web2c/xetexdir/xetex.h b/Build/source/texk/web2c/xetexdir/xetex.h index ebce1151bff..73d8f95502d 100644 --- a/Build/source/texk/web2c/xetexdir/xetex.h +++ b/Build/source/texk/web2c/xetexdir/xetex.h @@ -111,6 +111,9 @@ authorization from the copyright holders. #define UTF16LE 3 #define RAW 4 #define ICUMAPPING 5 +#ifdef WIN32 +#define WIN32CONSOLE 6 +#endif /* we don't use xchr, so change the cpascal.h definition of this... */ #undef Xchr |