]> matita.cs.unibo.it Git - helm.git/blob - helm/software/share/texmf/unicode/utf8x.def
Preparing for 0.5.9 release.
[helm.git] / helm / software / share / texmf / unicode / utf8x.def
1 %%
2 %% This is file `utf8x.def',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% ucs.dtx  (with options: `utf8x.def')
8 %% 
9 %% Copyright 2001 Dominique Unruh <dominique@unruh.de>
10 %% 
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)
14 %% for information.
15 %% 
16 \ifx\ProvidesFile\undefined\else
17 \ProvidesFile{utf8x.def}[2004/10/17 UCS: Input encoding UTF-8]%
18 \fi
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}%
28 \fi
29 \ifx\AtEndOfPackage\undefined\else
30 \ifx\@nodocument\relax\else\AtEndOfPackage{\RequirePackage{ucs}}\fi%
31 \fi
32 \def\utf@viii@err#1{%
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{%
36   \ifx\empty#3%
37   \count#1=-1\relax
38   \PackageError{utf8x}{Malformed UTF-8 sequence}{%
39     If the character is an argument, put it in {}}\else
40   \count#1=#3\fi}
41 \def\utf@viii@undef#1#2#3#4{%
42   \begingroup
43   \count0=#1\relax
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
50   \else
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
68   \multiply\count0by64%
69   \advance\count0by\count1%
70   \multiply\count0by64%
71   \advance\count0by\count2%
72   \multiply\count0by64%
73   \advance\count0by\count3%
74   \advance\count0by-"3C82080\relax
75   \fi\fi
76   \begingroup\expandafter\utf@viii@map\expandafter{\number\count0}\endgroup
77   \expandafter\endgroup
78   \expandafter\unichar\expandafter{\number\count0}}%
79 \def\utf@viii@make#1#2#3#4#5#6{%
80  \count255=#1\relax
81  \loop\ifnum\count255<#2\relax
82  \catcode\count255\active
83  \begingroup
84    \uccode`\~\count255%
85    \uccode`\u`\u%
86    \uppercase{%
87  \endgroup
88    \edef~%
89  #3{\noexpand\expandafter\noexpand\ifx\noexpand\csname u8-\number\count255-#4\noexpand\endcsname\relax
90    \begingroup
91      \let\noexpand\utf@viii@undeferr
92      \noexpand\@gobble\noexpand\empty\noexpand\empty
93      \noexpand\empty\noexpand\empty\noexpand\@gobbletwo\relax\relax
94      % ===
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%
100  \noexpand\else
101    \noexpand\expandafter\noexpand\unichar\noexpand\expandafter{%
102      \noexpand\csname u8-\number\count255-#4\noexpand\endcsname}\noexpand\fi}}%
103  \advance\count255by1\relax
104  \repeat}%
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}%
110   \count255=128\relax
111   \loop\ifnum\count255<192\relax
112   \catcode\count255\active
113   \begingroup
114     \uccode`\~\count255 %SPACE
115     \uppercase{%
116   \endgroup
117     \edef~}%
118   {\noexpand\utf@viii@err{\number\count255}}%
119  \advance\count255by1\relax
120  \repeat}%
121 \def\utf@viii@map#1{%
122   \begingroup
123   \count0=#1\divide\count0by64\relax
124   \ifnum#1<"80\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
129     \begingroup
130       \lccode`\B=\count1 %SPACE
131       \lowercase{%
132     \endgroup
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%
138     \divide\count1by64%
139     \advance\count0by224\advance\count1by128\advance\count2by128 %SPACE
140     \begingroup
141       \lccode`\B=\count1 %SPACE
142       \lccode`\C=\count2 %SPACE
143       \lowercase{%
144     \endgroup
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%
150     \divide\count2by64%
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
156     \begingroup
157       \lccode`\B=\count1 %SPACE
158       \lccode`\C=\count2 %SPACE
159       \lccode`\D=\count3 %SPACE
160       \lowercase{%
161     \endgroup
162       \expandafter\gdef\csname u8-\number\count0-BCD\endcsname}{#1}%
163   \else
164     \PackageWarning{utf8x}{Invalid code position \number#1 \uc@spc
165       defined,\MessageBreak unrepresentable in UTF-8}%
166   \fi\fi\fi\fi
167   \endgroup
168 }
169 \begingroup
170   \lccode`\A=`\{\lccode`\B=`\}\lccode`\C=`\\%
171   \lccode`\P=`\P\lccode`\U=`\U%
172   \lowercase{%
173 \endgroup
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
178     \AtBeginDocument{%
179     \begingroup
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
188       \lowercase{%
189       \expandafter\expandafter\expandafter\temp@a\expandafter\meaning\expandafter~%
190         \string\utf@viii@\@nil}%
191     \else
192       \count2\count0\fi
193     \advance\count0by1 %SPACE
194     \repeat
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
200     \fi\fi
201     \endgroup}%
202   \fi
203 \fi
204 \catcode`\@=\count255\relax
205 \csname restore@utf@viii@actives\endcsname