2 %% This is file `utf8x.def',
3 %% generated with the docstrip utility.
5 %% The original source files were:
7 %% ucs.dtx (with options: `utf8x.def')
9 %% Copyright 2001 Dominique Unruh <dominique@unruh.de>
11 %% This program is provided under the terms of the LaTeX Project Public
12 %% License with some modifications.
13 %% See the file LICENSE (http://www.unruh.de/DniQ/latex/unicode/content/LICENSE)
16 \ifx\ProvidesFile\undefined\else
17 \ProvidesFile{utf8x.def}[2004/10/17 UCS: Input encoding UTF-8]%
19 \expandafter\ifx\csname restore@utf@viii@actives\endcsname\relax\else
20 \csname restore@utf@viii@actives\endcsname\expandafter\endinput\fi
21 \count255=\catcode`\@\catcode`\@11 %SPACE
22 \ifx\@gobble\undefined\def\@gobble#1{}\fi
23 \ifx\@gobbletwo\undefined\def\@gobbletwo#1#2{}\fi
24 \ifx\AtBeginDocument\undefined\else
25 \ifx\@nodocument\relax\else\expandafter\AtBeginDocument\fi
26 {\ifx\unichar\undefined{\PackageError{utf8x}{%
27 Please use \protect\usepackage{ucs} to support encoding utf8x}{}}\fi}%
29 \ifx\AtEndOfPackage\undefined\else
30 \ifx\@nodocument\relax\else\AtEndOfPackage{\RequirePackage{ucs}}\fi%
33 \PackageError{utf8x}{Character \number#1 \uc@spc appeared alone}{%
34 Characters 128-191 are only allowed as arguments to characters 194-244}}
35 \def\utf@viii@xnum#1#2\utf@viii@err#3#4\@nil{%
38 \PackageError{utf8x}{Malformed UTF-8 sequence}{%
39 If the character is an argument, put it in {}}\else
41 \def\utf@viii@undef#1#2#3#4{%
44 \ifx#3\@nil % Two-byte sequences
45 \expandafter\utf@viii@xnum\expandafter1#2\empty\empty\empty\empty\empty\empty\empty\empty\empty\utf@viii@err\empty\@nil
46 \ifnum\count1=-1 \count0=192\count1="1007D\fi
47 \multiply\count0by64\relax
48 \advance\count0by\count1\relax
49 \advance\count0by-12416\relax
51 \ifx#4\@nil % Three-byte sequences
52 \expandafter\utf@viii@xnum\expandafter1#2\empty\empty\empty\empty\empty\empty\empty\empty\empty\utf@viii@err\empty\@nil
53 \expandafter\utf@viii@xnum\expandafter2#3\empty\empty\empty\empty\empty\empty\empty\empty\empty\utf@viii@err\empty\@nil
54 \ifnum\count1=-1 \count0=224\count1=128\count2="1007D\fi
55 \ifnum\count2=-1 \count0=224\count1=128\count2="1007D\fi
56 \multiply\count0by64\relax
57 \advance\count0by\count1\relax
58 \multiply\count0by64\relax
59 \advance\count0by\count2\relax
60 \advance\count0by-925824\relax
61 \else % Four-byte sequences
62 \expandafter\utf@viii@xnum\expandafter1#2\empty\empty\empty\empty\empty\empty\empty\empty\empty\utf@viii@err\empty\@nil
63 \expandafter\utf@viii@xnum\expandafter2#3\empty\empty\empty\empty\empty\empty\empty\empty\empty\utf@viii@err\empty\@nil
64 \expandafter\utf@viii@xnum\expandafter3#4\empty\empty\empty\empty\empty\empty\empty\empty\empty\utf@viii@err\empty\@nil
65 \ifnum\count1=-1 \count0=240\count1=128\count2=128\count3="1007D\fi
66 \ifnum\count2=-1 \count0=240\count1=128\count2=128\count3="1007D\fi
67 \ifnum\count3=-1 \count0=240\count1=128\count2=128\count3="1007D\fi
69 \advance\count0by\count1%
71 \advance\count0by\count2%
73 \advance\count0by\count3%
74 \advance\count0by-"3C82080\relax
76 \begingroup\expandafter\utf@viii@map\expandafter{\number\count0}\endgroup
78 \expandafter\unichar\expandafter{\number\count0}}%
79 \def\utf@viii@make#1#2#3#4#5#6{%
81 \loop\ifnum\count255<#2\relax
82 \catcode\count255\active
89 #3{\noexpand\expandafter\noexpand\ifx\noexpand\csname u8-\number\count255-#4\noexpand\endcsname\relax
91 \let\noexpand\utf@viii@undeferr
92 \noexpand\@gobble\noexpand\empty\noexpand\empty
93 \noexpand\empty\noexpand\empty\noexpand\@gobbletwo\relax\relax
95 \noexpand\expandafter\endgroup
96 % If \let not executed: \utf@viii@undeferr is called
97 % otherwise: \utf@viii@undef.
98 \noexpand\utf@viii@undeferr{\noexpand\string\noexpand~\noexpand\string#6}%
99 \noexpand\utf@viii@undef{\number\count255}#5%
101 \noexpand\expandafter\noexpand\unichar\noexpand\expandafter{%
102 \noexpand\csname u8-\number\count255-#4\noexpand\endcsname}\noexpand\fi}}%
103 \advance\count255by1\relax
105 \def\restore@utf@viii@actives{%
106 \let\@inpenc@test\relax
107 \utf@viii@make{194}{224}{####1}{\noexpand\string####1}{{####1}\noexpand\@nil\noexpand\@nil}{####1}%
108 \utf@viii@make{224}{240}{####1####2}{\noexpand\string####1\noexpand\string####2}{{####1}{####2}\noexpand\@nil}{####1\noexpand\string####2}%
109 \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}%
111 \loop\ifnum\count255<192\relax
112 \catcode\count255\active
114 \uccode`\~\count255 %SPACE
118 {\noexpand\utf@viii@err{\number\count255}}%
119 \advance\count255by1\relax
121 \def\utf@viii@map#1{%
123 \count0=#1\divide\count0by64\relax
125 % ASCII is not handled by utf8x.def
126 \else\ifnum#1<"800\relax
127 \count1=-\count0\multiply\count1by64\advance\count1by#1\relax
128 \advance\count0by192\advance\count1by128\relax
130 \lccode`\B=\count1 %SPACE
133 \expandafter\gdef\csname u8-\number\count0-B\endcsname}{#1}%
134 \else\ifnum#1<"10000\relax
135 \count2=-\count0\multiply\count2by64\advance\count2by#1\relax
136 \divide\count0by64 %SPACE
137 \count1=-\count0\multiply\count1by4096\advance\count1by#1%
139 \advance\count0by224\advance\count1by128\advance\count2by128 %SPACE
141 \lccode`\B=\count1 %SPACE
142 \lccode`\C=\count2 %SPACE
145 \expandafter\gdef\csname u8-\number\count0-BC\endcsname}{#1}%
146 \else\ifnum#1<"110000 %SPACE
147 \count3=-\count0\multiply\count3by64\advance\count3by#1\relax
148 \divide\count0by64 %SPACE
149 \count2=-\count0\multiply\count2by4096\advance\count2by#1%
151 \divide\count0by64 %SPACE
152 \count1=-\count0\multiply\count1by262144\advance\count1by#1%
153 \divide\count1by4096 %SPACE
154 \advance\count0by240\advance\count1by128%
155 \advance\count2by128\advance\count3by128 %SPACE
157 \lccode`\B=\count1 %SPACE
158 \lccode`\C=\count2 %SPACE
159 \lccode`\D=\count3 %SPACE
162 \expandafter\gdef\csname u8-\number\count0-BCD\endcsname}{#1}%
164 \PackageWarning{utf8x}{Invalid code position \number#1 \uc@spc
165 defined,\MessageBreak unrepresentable in UTF-8}%
170 \lccode`\A=`\{\lccode`\B=`\}\lccode`\C=`\\%
171 \lccode`\P=`\P\lccode`\U=`\U%
174 \def\utf@viii@undeferr#1#2#3#4#5#6{%
175 \ifx\@gobble#1\else[Please insert CPrerenderUnicodeA#1B into preamble]\fi}}
176 \ifx\AtBeginDocument\undefined\else
177 \ifx\@nodocument\relax\else
180 \expandafter\def\expandafter\temp@a\expandafter#\expandafter1%
181 \string\utf@viii@#2\@nil{%
182 \ifx\@nil#2\@nil\count2\count0\else\count1\count0\fi}%
183 \count0=128 \count1=0 \count2=0 %SPACE
184 \loop\ifnum\count0<245 %SPACE
185 \ifnum\count0=192 \advance\count0by2 \fi
186 \lccode`\~\count0 %SPACE
187 \ifnum\catcode\count0=13 %SPACE
189 \expandafter\expandafter\expandafter\temp@a\expandafter\meaning\expandafter~%
190 \string\utf@viii@\@nil}%
193 \advance\count0by1 %SPACE
195 \ifnum\count1=0 \else\ifnum\count2=0 \else
196 \PackageWarning{utf8x.def}{Character(s) \number\count2\space\space
197 etc. got redefined somewhere.\MessageBreak
198 Restoring to its utf8x-meaning}%
199 \aftergroup\restore@utf@viii@actives
204 \catcode`\@=\count255\relax
205 \csname restore@utf@viii@actives\endcsname