forked from zr-tex8r/PXjahyper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpxjahyper-uni.def
104 lines (93 loc) · 2.78 KB
/
pxjahyper-uni.def
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
%%
%% This is file 'pxjahyper-uni.def'.
%%
%% Copyright (c) 2012-2022 Takayuki YATO (aka. "ZR")
%% GitHub: https://github.com/zr-tex8r
%% Twitter: @zr_tex8r
%%
%% This package is distributed under the MIT License.
%%
%% package declaration
\NeedsTeXFormat{pLaTeX2e}
\ProvidesFile{pxjahyper-uni.def}[2022/05/27 v1.2]
\providecommand{\bxDebug}[1]{}
%--------------------------------------- environment check
\@ifpackageloaded{hyperref}{}{%else
\bxDebug{pxjahyper-uni: hyperref not yet loaded}%
\endinput}
%% if already redefined, then okay
\def\pxhy@tmpa#1{\@backslashchar 000#1}
\ifx\HyPsd@Char\pxhy@tmpa\else
\bxDebug{pxjahyper-uni: already redefined}
\let\jsCheckHyperrefUnicode\@empty
\expandafter\endinput\fi\relax
%% if this is pTeX and pxjatoucs is not loaded, then quit
\if \ifnum\jis"2121="3000 F%
\else\ifx\bxjaSjisToUcs\@undefined T\else F%
\fi\fi T%
\bxDebug{pxjahyper-uni: bxjatoucs not yet loaded}
\expandafter\endinput\fi\relax
%--------------------------------------- the patch
%% The following code is taken from hyperref.sty.
%%%%BEGIN
\def\HyPsd@Char#1{%
\ifnum`#1<128 %
\@backslashchar 000#1%
\else
\ifnum`#1<65536 %
\expandafter\HyPsd@CharTwoByte\number`#1!%
\else
\expandafter\expandafter\expandafter\HyPsd@CharSurrogate
\intcalcSub{`#1}{65536}!%
\fi
\fi
}%
\def\HyPsd@CharTwoByte#1!{%
\expandafter\expandafter\expandafter\HyPsd@CharOctByte
\IntCalcDiv#1!256!!%
\expandafter\expandafter\expandafter\HyPsd@CharOctByte
\IntCalcMod#1!256!!%
}%
\def\HyPsd@CharOctByte#1!{%
\@backslashchar
\IntCalcDiv#1!64!%
\intcalcDiv{\IntCalcMod#1!64!}{8}%
\IntCalcMod#1!8!%
}%
\def\HyPsd@CharSurrogate#1!{%
\@backslashchar 33%
\IntCalcDiv#1!262144!%
\expandafter\expandafter\expandafter\HyPsd@CharOctByte
\intcalcDiv{\IntCalcMod#1!262144!}{1024}!%
\@backslashchar 33%
\expandafter\expandafter\expandafter\IntCalcAdd
\intcalcDiv{\IntCalcMod#1!1024!}{256}!4!%
\expandafter\expandafter\expandafter\HyPsd@CharOctByte
\IntCalcMod#1!256!!%
}%
%%%%END
\ifnum\jis"2121="3000 \else %<*pTeX>
\def\HyPsd@Char#1{%
\ifnum`#1<128 %
\@backslashchar 000#1%
\else\ifnum`#1<256 %
\expandafter\HyPsd@CharTwoByte\number`#1!%
\else
\expandafter\HyPsd@CharTwoByte\number\pxhy@to@ucs{`#1}!%
\fi\fi
}%
\def\pxhy@to@ucs#1{"FFFD}
\ifnum\jis"2121="8140 % sjis
\let\pxhy@to@ucs\bxjaSjisToUcs
\else\ifnum\jis"2121="A1A1 % euc
\let\pxhy@to@ucs\bxjaEucToUcs
\fi\fi
\fi %</pTeX>
%% set flag
\let\pxHyperrefUnicodePatched=t
\bxDebug{pxjahyper-uni: patched}
%% disable the verification of bxjscls
\let\jsCheckHyperrefUnicode\@empty
%--------------------------------------- done
\endinput
%% EOF