Skip to content

Instantly share code, notes, and snippets.

@dohyunkim
Created March 4, 2021 08:19
Show Gist options
  • Save dohyunkim/82212593776608f0a4578a140ace3fba to your computer and use it in GitHub Desktop.
Save dohyunkim/82212593776608f0a4578a140ace3fba to your computer and use it in GitHub Desktop.
XeTeX character classes
\documentclass{minimal}
\chardef\XeTeXcharclassIgnore=4096
\chardef\XeTeXcharclassBoundary=4095
\newXeTeXintercharclass\XeTeXcharclassID
\newXeTeXintercharclass\XeTeXcharclassCJ
\newXeTeXintercharclass\XeTeXcharclassOP
\newXeTeXintercharclass\XeTeXcharclassCL
\newXeTeXintercharclass\XeTeXcharclassEX
\newXeTeXintercharclass\XeTeXcharclassIS
\newXeTeXintercharclass\XeTeXcharclassNS
\let\XeTeXcharclassCM\XeTeXcharclassIgnore
\input load-unicode-xetex-classes %
\begin{document}
\def\hex{%
\def\TMP{}%
\dohex
}
\def\dohex{{%
\count0=\n
\divide\n by16
\ifnum\n>0
\dohex
\fi
\count2=\n
\multiply\count2 by-16
\advance\count0 by\count2
\hexdigit
}}
\def\hexdigit{%
\ifnum\count0<10
\xdef\TMP{\TMP \the\count0 }%
\else
\advance\count0 by-10
\xdef\TMP{\TMP \ifcase\count0 A\or B\or C\or D\or E\or F\else ???\fi }%
\fi
}
\newcount\n \newcount\m
\def\printclasses{%
\m=\XeTeXcharclass\n
\ifnum\m > 0 %
\hex
\typeout{%
\Uchar\n \space :
\ifcase\m \or ID\or CJ\or OP\or CL\or EX\or IS\or NS\else CM\fi \space:
\the\m \space :
\TMP
}%
\fi
\ifnum\n<"FFFD
\advance\n by1
\expandafter\printclasses
\fi
}
\typeout{char : class_type : class_number : unicode}
\n=1
\printclasses
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment