[issue:252] Fwd: regexpatch: error on (u)pTeX with Japanese char

Hironobu Yamashita h.y.acetaminophen @ gmail.com
2019年 1月 17日 (木) 11:37:45 JST


前に転送した egreg さんのメールに対する私の返信です。 -- Hironobu Yamashita


---------- Forwarded message ----------
From: Hironobu Yamashita <h.y.acetaminophen @ gmail.com>
Date: Wed, 16 Jan 2019 23:25:36 +0900
Subject: Re: regexpatch: error on (u)pTeX with Japanese char
To: Enrico Gregorio <enrico.gregorio @ univr.it>

Hi,

The problem seems to be solved, but just for your information:

> If there is a sane way to check whether a character token will
> give a character code illegal with \catcode, then I guess a
> further check can be added when the engine is epTeX.

I think you can detect whether a character token is JP char
or non-JP char by following code, for example.
By design, the behavior of \kcatcode is different between
pTeX and upTeX (the latter one allows flexible changing of
JP / non-JP classification), so different code should be used here.

\ifx\enablecjktoken\@undefined
\def\@ifisjp#1{% pTeX version
  \ifnum`#1<255\relax
    \expandafter\@secondoftwo % non-JP
  \else
    \expandafter\@firstoftwo % JP
  \fi}
\else
\def\@ifisjp#1{% upTeX version
  \ifnum\kcatcode`#1=15\relax
    \expandafter\@secondoftwo % non-JP
  \else
    \expandafter\@firstoftwo % JP
  \fi}
\fi

The test case is shown at
https://gist.github.com/aminophen/154cb16cfe989dd605b0983f3e3bd20b

Best regards,
Hironobu


issue メーリングリストの案内