Skip to content

Instantly share code, notes, and snippets.

@h-kitagawa
Created June 12, 2019 04:58
Show Gist options
  • Save h-kitagawa/a26fc6d25cdf68a4aa9833c3bfb54e9f to your computer and use it in GitHub Desktop.
Save h-kitagawa/a26fc6d25cdf68a4aa9833c3bfb54e9f to your computer and use it in GitHub Desktop.
platex/#84 に対する修正実験
\documentclass{minimal}
\makeatletter
\ifdefined\kanjiskip
\unless\ifdefined\ucs % (e-)pTeX only
%%%% EUC-JP が内部漢字コードであることを想定
\begingroup
\catcode`\"=12
\catcode`\<=12
\catcode`\.=12
\catcode`\,=12
\catcode`\;=12
\catcode`\!=12
\catcode`\~=13
\gdef\UTFviii@splitcsname#1:#2\relax{%
%
\pltx@UTFviii@tobyte#2\relax\space
(\expandafter\UTFviii@hexcodepoint\expandafter{%
\the\numexpr\decode@UTFviii#2\relax})%
}
\endgroup
\begingroup
\count@="80
\lccode`\U=`\U
\lccode`\T=`\T
\lccode`\F=`\F
\loop\ifnum\count@<"100
\lccode`\:=\count@
\lowercase{\expandafter\gdef\csname pltx@UTFviii@\the\count@\endcsname
{:}}%
\advance\count@ 1
\repeat
\endgroup
\def\pltx@UTFviii@tobyte#1{%
\ifx#1\relax\else
\ifnum`#1<"100 #1\else
\expandafter\expandafter\expandafter\strip@prefix
\expandafter\meaning
\csname pltx@UTFviii@\the\numexpr (`#1-"7F)/"100\relax\endcsname
\expandafter\expandafter\expandafter\strip@prefix
\expandafter\meaning
\csname pltx@UTFviii@\the\numexpr
`#1-(`#1/256)*256+256 \relax\endcsname
\fi
\expandafter\pltx@UTFviii@tobyte\fi
}
\def\UTFviii@checkseq#1:#2#3{%
\ifnum`#2<"80 %
\ifx\relax#3\else1\fi
\else
\ifnum`#2<"C0 %
1 %
\else
\expandafter\expandafter\expandafter\UTFviii@check@continue
\expandafter\expandafter\expandafter#3%
\fi
\fi}
\def\UTFviii@check@continue#1{%
\ifx\relax#1%
\else
\ifnum`#1<"80 1\else\ifnum`#1>"BF
\ifnum`#1<"807F 1\else\ifnum`#1>"BFBF 1\fi\fi
\fi\fi
\expandafter\UTFviii@check@continue
\fi
}
\def\dec@de@UTFviii#1{%
\ifx\relax#1%
\else
\ifnum`#1>"EFFF
((((`#1/256-"F0-1)*64
+`#1-(`#1/256)*256+256-"80
\else\ifnum`#1>"DFFF
(((`#1/256-"E0-1)*64
+`#1-(`#1/256)*256+256-"80
\else\ifnum`#1>"BFFF
((`#1/256-"C0-1)*64
+`#1-(`#1/256)*256+256-"80
\else\ifnum`#1>"7FFF % third and fourth bytes
)*4096+(`#1/256-"80-1)*64
+`#1-(`#1/256)*256+256-"80
\else\ifnum`#1>"EF
((((`#1-"F0)%
\else
\ifnum`#1>"DF
(((`#1-"E0)%
\else
\ifnum`#1>"BF
((`#1-"C0)%
\else
\ifnum`#1>"7F
)*64+(`#1-"80)%
\else
+`#1 %
\fi
\fi
\fi
\fi
\fi\fi\fi\fi
\expandafter\dec@de@UTFviii
\fi}
\fi\fi
\begin{document}
Ƀ % U+0243 ^^c9^^83
ſ % U+017F ^^c5^^bf
껟 % U+AEDF ^^ea^^bb^^9f
𢄀 % U+22100 ^^f0^^a2^^84^^80
𠢣 % U+208A3 ^^f0^^a0^^a2^^a3
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment