summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ucs/utf8x.def
blob: 6970ac297c7d11822d0f50d2e20781605e3d6ee8 (plain)
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
%%
%% This is file `utf8x.def',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ucs.dtx  (with options: `utf8x.def')
%% 
%% Copyright 2001 Dominique Unruh  <unruh@ut.ee>
%% Copyright 2013 Wolfgang Jeltsch <wolfgang@cs.ioc.ee>
%% 
%% This program is provided under the terms of the LaTeX Project Public License with some
%% modifications. See the file LICENSE for information.
%% 
\ifx\ProvidesFile\undefined\else
\ProvidesFile{utf8x.def}[2004/10/17 UCS: Input encoding UTF-8]%
\fi
\expandafter\ifx\csname restore@utf@viii@actives\endcsname\relax\else
  \csname restore@utf@viii@actives\endcsname\expandafter\endinput\fi
\count255=\catcode`\@\catcode`\@11 %SPACE
\ifx\@gobble\undefined\def\@gobble#1{}\fi
\ifx\@gobbletwo\undefined\def\@gobbletwo#1#2{}\fi
\ifx\AtBeginDocument\undefined\else
  \ifx\@nodocument\relax\else\expandafter\AtBeginDocument\fi
  {\ifx\unichar\undefined{\PackageError{utf8x}{%
        Please use \protect\usepackage{ucs} to support encoding utf8x}{}}\fi}%
\fi
\ifx\AtEndOfPackage\undefined\else
\ifx\@nodocument\relax\else\AtEndOfPackage{\RequirePackage{ucs}}\fi%
\fi
\def\utf@viii@err#1{%
  \PackageError{utf8x}{Character \number#1 \uc@spc appeared alone}{%
    Characters 128-191 are only allowed as arguments to characters 194-244}}
\def\utf@viii@xnum#1#2\utf@viii@err#3#4\@nil{%
  \ifx\empty#3%
  \count#1=-1\relax
  \PackageError{utf8x}{Malformed UTF-8 sequence}{%
    If the character is an argument, put it in {}}\else
  \count#1=#3\fi}
\def\utf@viii@undef#1#2#3#4{%
  \begingroup
  \count0=#1\relax
  \ifx#3\@nil  % Two-byte sequences
  \expandafter\utf@viii@xnum\expandafter1#2\empty\empty\empty\empty\empty\empty\empty\empty\empty\utf@viii@err\empty\@nil
  \ifnum\count1=-1 \count0=192\count1="1007D\fi
  \multiply\count0by64\relax
  \advance\count0by\count1\relax
  \advance\count0by-12416\relax
  \else
  \ifx#4\@nil  % Three-byte sequences
  \expandafter\utf@viii@xnum\expandafter1#2\empty\empty\empty\empty\empty\empty\empty\empty\empty\utf@viii@err\empty\@nil
  \expandafter\utf@viii@xnum\expandafter2#3\empty\empty\empty\empty\empty\empty\empty\empty\empty\utf@viii@err\empty\@nil
  \ifnum\count1=-1 \count0=224\count1=128\count2="1007D\fi
  \ifnum\count2=-1 \count0=224\count1=128\count2="1007D\fi
  \multiply\count0by64\relax
  \advance\count0by\count1\relax
  \multiply\count0by64\relax
  \advance\count0by\count2\relax
  \advance\count0by-925824\relax
  \else  % Four-byte sequences
  \expandafter\utf@viii@xnum\expandafter1#2\empty\empty\empty\empty\empty\empty\empty\empty\empty\utf@viii@err\empty\@nil
  \expandafter\utf@viii@xnum\expandafter2#3\empty\empty\empty\empty\empty\empty\empty\empty\empty\utf@viii@err\empty\@nil
  \expandafter\utf@viii@xnum\expandafter3#4\empty\empty\empty\empty\empty\empty\empty\empty\empty\utf@viii@err\empty\@nil
  \ifnum\count1=-1 \count0=240\count1=128\count2=128\count3="1007D\fi
  \ifnum\count2=-1 \count0=240\count1=128\count2=128\count3="1007D\fi
  \ifnum\count3=-1 \count0=240\count1=128\count2=128\count3="1007D\fi
  \multiply\count0by64%
  \advance\count0by\count1%
  \multiply\count0by64%
  \advance\count0by\count2%
  \multiply\count0by64%
  \advance\count0by\count3%
  \advance\count0by-"3C82080\relax
  \fi\fi
  \begingroup\expandafter\utf@viii@map\expandafter{\number\count0}\endgroup
  \expandafter\endgroup
  \expandafter\unichar\expandafter{\number\count0}}%
\def\utf@viii@make#1#2#3#4#5#6{%
 \count255=#1\relax
 \loop\ifnum\count255<#2\relax
 \catcode\count255\active
 \begingroup
   \uccode`\~\count255%
   \uccode`\u`\u%
   \uppercase{%
 \endgroup
   \edef~%
 #3{\noexpand\expandafter\noexpand\ifx\noexpand\csname u8-\number\count255-#4\noexpand\endcsname\relax
   \begingroup
     \let\noexpand\utf@viii@undeferr
     \noexpand\@gobble\noexpand\empty\noexpand\empty
     \noexpand\empty\noexpand\empty\noexpand\@gobbletwo\relax\relax
     % ===
   \noexpand\expandafter\endgroup
   % If \let not executed: \utf@viii@undeferr is called
   % otherwise: \utf@viii@undef.
   \noexpand\utf@viii@undeferr{\noexpand\string\noexpand~\noexpand\string#6}%
     \noexpand\utf@viii@undef{\number\count255}#5%
 \noexpand\else
   \noexpand\expandafter\noexpand\unichar\noexpand\expandafter{%
     \noexpand\csname u8-\number\count255-#4\noexpand\endcsname}\noexpand\fi}}%
 \advance\count255by1\relax
 \repeat}%
\def\restore@utf@viii@actives{%
  \let\@inpenc@test\relax
  \utf@viii@make{194}{224}{####1}{\noexpand\string####1}{{####1}\noexpand\@nil\noexpand\@nil}{####1}%
  \utf@viii@make{224}{240}{####1####2}{\noexpand\string####1\noexpand\string####2}{{####1}{####2}\noexpand\@nil}{####1\noexpand\string####2}%
  \utf@viii@make{240}{245}{####1####2####3}{\noexpand\string####1\noexpand\string####2\noexpand\string####3}{{####1}{####2}{####3}}{####1\noexpand\string####2\noexpand\string####3}%
  \count255=128\relax
  \loop\ifnum\count255<192\relax
  \catcode\count255\active
  \begingroup
    \uccode`\~\count255 %SPACE
    \uppercase{%
  \endgroup
    \edef~}%
  {\noexpand\utf@viii@err{\number\count255}}%
 \advance\count255by1\relax
 \repeat}%
\def\utf@viii@map#1{%
  \begingroup
  \count0=#1\divide\count0by64\relax
  \ifnum#1<"80\relax
  % ASCII is not handled by utf8x.def
  \else\ifnum#1<"800\relax
    \count1=-\count0\multiply\count1by64\advance\count1by#1\relax
    \advance\count0by192\advance\count1by128\relax
    \begingroup
      \lccode`\B=\count1 %SPACE
      \lowercase{%
    \endgroup
      \expandafter\gdef\csname u8-\number\count0-B\endcsname}{#1}%
  \else\ifnum#1<"10000\relax
    \count2=-\count0\multiply\count2by64\advance\count2by#1\relax
    \divide\count0by64 %SPACE
    \count1=-\count0\multiply\count1by4096\advance\count1by#1%
    \divide\count1by64%
    \advance\count0by224\advance\count1by128\advance\count2by128 %SPACE
    \begingroup
      \lccode`\B=\count1 %SPACE
      \lccode`\C=\count2 %SPACE
      \lowercase{%
    \endgroup
      \expandafter\gdef\csname u8-\number\count0-BC\endcsname}{#1}%
  \else\ifnum#1<"110000 %SPACE
    \count3=-\count0\multiply\count3by64\advance\count3by#1\relax
    \divide\count0by64 %SPACE
    \count2=-\count0\multiply\count2by4096\advance\count2by#1%
    \divide\count2by64%
    \divide\count0by64 %SPACE
    \count1=-\count0\multiply\count1by262144\advance\count1by#1%
    \divide\count1by4096 %SPACE
    \advance\count0by240\advance\count1by128%
    \advance\count2by128\advance\count3by128 %SPACE
    \begingroup
      \lccode`\B=\count1 %SPACE
      \lccode`\C=\count2 %SPACE
      \lccode`\D=\count3 %SPACE
      \lowercase{%
    \endgroup
      \expandafter\gdef\csname u8-\number\count0-BCD\endcsname}{#1}%
  \else
    \PackageWarning{utf8x}{Invalid code position \number#1 \uc@spc
      defined,\MessageBreak unrepresentable in UTF-8}%
  \fi\fi\fi\fi
  \endgroup
}
\begingroup
  \lccode`\A=`\{\lccode`\B=`\}\lccode`\C=`\\%
  \lccode`\P=`\P\lccode`\U=`\U%
  \lowercase{%
\endgroup
  \def\utf@viii@undeferr#1#2#3#4#5#6{%
    \ifx\@gobble#1\else[Please insert CPrerenderUnicodeA#1B into preamble]\fi}}
\ifx\AtBeginDocument\undefined\else
  \ifx\@nodocument\relax\else
    \AtBeginDocument{%
    \begingroup
    \expandafter\def\expandafter\temp@a\expandafter#\expandafter1%
      \string\utf@viii@#2\@nil{%
        \ifx\@nil#2\@nil\count2\count0\else\count1\count0\fi}%
    \count0=128 \count1=0 \count2=0 %SPACE
    \loop\ifnum\count0<245 %SPACE
    \ifnum\count0=192 \advance\count0by2 \fi
    \lccode`\~\count0 %SPACE
    \ifnum\catcode\count0=13 %SPACE
      \lowercase{%
      \expandafter\expandafter\expandafter\temp@a\expandafter\meaning\expandafter~%
        \string\utf@viii@\@nil}%
    \else
      \count2\count0\fi
    \advance\count0by1 %SPACE
    \repeat
    \ifnum\count1=0 \else\ifnum\count2=0 \else
      \PackageWarning{utf8x.def}{Character(s) \number\count2\space\space
        etc. got redefined somewhere.\MessageBreak
        Restoring to its utf8x-meaning}%
      \aftergroup\restore@utf@viii@actives
    \fi\fi
    \endgroup}%
  \fi
\fi
\catcode`\@=\count255\relax
\csname restore@utf@viii@actives\endcsname