Debian Codegraph @

texmf-dist/tex/latex/base/utf8.def

raw
1 %%
2 %% This is file `utf8.def',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% utf8ienc.dtx (with options: `utf8')
8 %%
9 %% This is a generated file.
10 %%
11 %% The source is maintained by the LaTeX Project team and bug
12 %% reports for it can be opened at https://latex-project.org/bugs.html
13 %% (but please observe conditions on bug reports sent to that address!)
14 %%
15 %%
16 %% Copyright (C) 1993-2025
17 %% The LaTeX Project and any individual authors listed elsewhere
18 %% in this file.
19 %%
20 %% This file was generated from file(s) of the LaTeX base system.
21 %% --------------------------------------------------------------
22 %%
23 %% It may be distributed and/or modified under the
24 %% conditions of the LaTeX Project Public License, either version 1.3c
25 %% of this license or (at your option) any later version.
26 %% The latest version of this license is in
27 %% https://www.latex-project.org/lppl.txt
28 %% and version 1.3c or later is part of all distributions of LaTeX
29 %% version 2008 or later.
30 %%
31 %% This file has the LPPL maintenance status "maintained".
32 %%
33 %% This file may only be distributed together with a copy of the LaTeX
34 %% base system. You may however distribute the LaTeX base system without
35 %% such generated files.
36 %%
37 %% The list of all files belonging to the LaTeX base distribution is
38 %% given in the file `manifest.txt'. See also `legal.txt' for additional
39 %% information.
40 %%
41 %% The list of derived (unpacked) files belonging to the distribution
42 %% and covered by LPPL is defined by the unpacking scripts (with
43 %% extension .ins) which are part of the distribution.
44 \ProvidesFile{utf8.def}
45 [2022/06/07 v1.3c UTF-8 support]
46 \ifx\ifincsname\@undefined % old e-pTeX or e-upTeX engines
47 \input utf8-2018.def
48 \expandafter\@firstofone
49 \else
50 \expandafter\@gobble
51 \fi
52 \endinput
53 \makeatletter
54 \catcode`\ \saved@space@catcode
55 \long\def\UTFviii@two@octets{%
56 \ifincsname
57 \expandafter \UTF@two@octets@string
58 \else
59 \ifx \protect\@typeset@protect \else
60 \expandafter\expandafter\expandafter \UTF@two@octets@noexpand
61 \fi
62 \fi
63 \UTFviii@two@octets@combine
64 }
65
66 \long\def\UTFviii@three@octets{%
67 \ifincsname
68 \expandafter \UTF@three@octets@string
69 \else
70 \ifx \protect\@typeset@protect \else
71 \expandafter\expandafter\expandafter \UTF@three@octets@noexpand
72 \fi
73 \fi
74 \UTFviii@three@octets@combine
75 }
76 \long\def\UTFviii@four@octets{%
77 \ifincsname
78 \expandafter \UTF@four@octets@string
79 \else
80 \ifx \protect\@typeset@protect \else
81 \expandafter\expandafter\expandafter \UTF@four@octets@noexpand
82 \fi
83 \fi
84 \UTFviii@four@octets@combine
85 }
86 \long\def\UTF@two@octets@noexpand#1#2#3{\unexpanded{#2#3}}
87 \long\def\UTF@three@octets@noexpand#1#2#3#4{\unexpanded{#2#3#4}}
88 \long\def\UTF@four@octets@noexpand#1#2#3#4#5{\unexpanded{#2#3#4#5}}
89
90 \long\def\UTF@two@octets@string#1#2#3{\detokenize{#2#3}}
91 \long\def\UTF@three@octets@string#1#2#3#4{\detokenize{#2#3#4}}
92 \long\def\UTF@four@octets@string#1#2#3#4#5{\detokenize{#2#3#4#5}}
93
94 \long\def\UTFviii@two@octets@combine#1#2{\expandafter
95 \UTFviii@defined\csname u8:\string#1\string#2\endcsname}
96 \long\def\UTFviii@three@octets@combine#1#2#3{\expandafter
97 \UTFviii@defined\csname u8:\string#1\string#2\string#3\endcsname}
98 \long\def\UTFviii@four@octets@combine#1#2#3#4{\expandafter
99 \UTFviii@defined\csname u8:\string#1\string#2\string#3\string#4\endcsname}
100 \def\UTFviii@defined#1{%
101 \ifx#1\relax
102 \if\relax\expandafter\UTFviii@checkseq\string#1\relax\relax
103 \UTFviii@undefined@err{#1}%
104 \else
105 \@latex@error{Invalid UTF-8 byte sequence (\expandafter
106 \@gobblefour\string#1)}%
107 \UTFviii@invalid@help
108 \fi
109 \else\expandafter
110 #1%
111 \fi
112 }
113 \def\UTFviii@invalid@err#1{%
114 \@latex@error{Invalid UTF-8 byte "\UTFviii@hexnumber{`#1}}%
115 \UTFviii@invalid@help}
116 \def\UTFviii@invalid@help{%
117 The document does not appear to be in UTF-8 encoding.\MessageBreak
118 Try adding \noexpand\UseRawInputEncoding as the first line of the file\MessageBreak
119 or specify an encoding such as \noexpand\usepackage[latin1]{inputenc}\MessageBreak
120 in the document preamble.\MessageBreak
121 Alternatively, save the file in UTF-8 using your editor or another tool}
122 \def\UTFviii@undefined@err#1{%
123 \@latex@error{Unicode character \expandafter
124 \UTFviii@splitcsname\string#1\relax
125 \MessageBreak
126 not set up for use with LaTeX}%
127 {You may provide a definition with\MessageBreak
128 \noexpand\DeclareUnicodeCharacter}%
129 }
130 \def\UTFviii@checkseq#1:#2#3{%
131 \ifnum`#2<"80 %
132 \ifx\relax#3\else1\fi
133 \else
134 \ifnum`#2<"C0 %
135 1 %
136 \else
137 \expandafter\expandafter\expandafter\UTFviii@check@continue
138 \expandafter\expandafter\expandafter#3%
139 \fi
140 \fi}
141 \def\UTFviii@check@continue#1{%
142 \ifx\relax#1%
143 \else
144 \ifnum`#1<"80 1\else\ifnum`#1>"BF 1\fi\fi
145 \expandafter\UTFviii@check@continue
146 \fi
147 }
148 \edef\reserved@a{%
149 \catcode`\noexpand\~=\the\catcode`\~\relax
150 \catcode`\noexpand\"=\the\catcode`\"\relax
151 \uccode`\noexpand\~=\the\uccode`\~\relax
152 \count@=\the\count@\relax
153 \@tempcnta=\the\@tempcnta\relax
154 \let\noexpand\reserved@a\relax}
155 \catcode`\~13
156 \catcode`\"12
157 \def\UTFviii@loop{%
158 \uccode`\~\count@
159 \uppercase\expandafter{\UTFviii@tmp}%
160 \advance\count@\@ne
161 \ifnum\count@<\@tempcnta
162 \expandafter\UTFviii@loop
163 \fi}
164 \def\UTFviii@tmp{\protected\edef~{\noexpand\UTFviii@undefined@err{:\string~}}}
165 \count@"1
166 \@tempcnta9
167 \UTFviii@loop
168 \count@11
169 \@tempcnta12
170 \UTFviii@loop
171 \count@14
172 \@tempcnta32
173 \UTFviii@loop
174 \count@"80
175 \@tempcnta"C2
176 \def\UTFviii@tmp{\protected\edef~{\noexpand\UTFviii@invalid@err\string~}}
177 \UTFviii@loop
178 \count@"C2
179 \@tempcnta"E0
180 \def\UTFviii@tmp{\protected\edef~{\noexpand\UTFviii@two@octets\noexpand~}}
181 \UTFviii@loop
182 \count@"E0
183 \@tempcnta"F0
184 \def\UTFviii@tmp{\protected\edef~{\noexpand\UTFviii@three@octets\noexpand~}}
185 \UTFviii@loop
186 \count@"F0
187 \@tempcnta"F5
188 \def\UTFviii@tmp{\protected\edef~{\noexpand\UTFviii@four@octets\noexpand~}}
189 \UTFviii@loop
190 \count@"F5
191 \@tempcnta"100
192 \def\UTFviii@tmp{\protected\edef~{\noexpand\UTFviii@invalid@err\string~}}
193 \UTFviii@loop
194 \reserved@a
195 \@inpenc@test
196 \ifx\@begindocumenthook\@undefined
197 \makeatother
198 \endinput \fi
199 \begingroup
200 \catcode`\"=12
201 \catcode`\<=12
202 \catcode`\.=12
203 \catcode`\,=12
204 \catcode`\;=12
205 \catcode`\!=12
206 \catcode`\~=13
207 \gdef\DeclareUnicodeCharacter#1#2{%
208 \count@"#1\relax
209 \wlog{ \space\space defining Unicode char U+#1 (decimal \the\count@)}%
210 \begingroup
211 \parse@XML@charref
212 \def\UTFviii@two@octets##1##2{\csname u8:##1\string##2\endcsname}%
213 \def\UTFviii@three@octets##1##2##3{\csname u8:##1%
214 \string##2\string##3\endcsname}%
215 \def\UTFviii@four@octets##1##2##3##4{\csname u8:##1%
216 \string##2\string##3\string##4\endcsname}%
217 \expandafter\expandafter\expandafter
218 \expandafter\expandafter\expandafter
219 \expandafter
220 \gdef\UTFviii@tmp{\IeC{#2}}%
221 \endgroup
222 }
223 \gdef\parse@XML@charref{%
224 \ifnum\count@<"80\relax
225 \ifnum\catcode\count@=13
226 \uccode`\~=\count@\uppercase{\def\UTFviii@tmp{\@empty\@empty~}}%
227 \else
228 \@latex@error{Cannot define non-active Unicode char value < 0080}%
229 \@eha
230 \def\UTFviii@tmp{\UTFviii@tmp}%
231 \fi
232 \else\ifnum\count@<"800\relax
233 \parse@UTFviii@a,%
234 \parse@UTFviii@b C\UTFviii@two@octets.,%
235 \else\ifnum\count@<"10000\relax
236 \parse@UTFviii@a;%
237 \parse@UTFviii@a,%
238 \parse@UTFviii@b E\UTFviii@three@octets.{,;}%
239 \else
240 \ifnum\count@>"10FFFF\relax
241 \@latex@error
242 {\UTFviii@hexnumber\count@\space too large for Unicode}%
243 {Values between 0 and 10FFFF are permitted}%
244 \fi
245 \parse@UTFviii@a;%
246 \parse@UTFviii@a,%
247 \parse@UTFviii@a!%
248 \parse@UTFviii@b F\UTFviii@four@octets.{!,;}%
249 \fi
250 \fi
251 \fi
252 }
253 \gdef\parse@UTFviii@a#1{%
254 \@tempcnta\count@
255 \divide\count@ 64
256 \@tempcntb\count@
257 \multiply\count@ 64
258 \advance\@tempcnta-\count@
259 \advance\@tempcnta 128
260 \uccode`#1\@tempcnta
261 \count@\@tempcntb}
262 \gdef\parse@UTFviii@b#1#2#3#4{%
263 \advance\count@ "#10\relax
264 \uccode`#3\count@
265 \uppercase{\gdef\UTFviii@tmp{#2#3#4}}}
266 \ifx\numexpr\@undefined
267 \gdef\decode@UTFviii#1{0}
268 \else
269 \gdef\decode@UTFviii#1\relax{%
270 \expandafter\UTFviii@cleanup
271 \the\numexpr\dec@de@UTFviii#1\relax)))))\@empty}
272 \gdef\UTFviii@cleanup#1)#2\@empty{#1}
273 \gdef\dec@de@UTFviii#1{%
274 \ifx\relax#1%
275 \else
276 \ifnum`#1>"EF
277 ((((`#1-"F0)%
278 \else
279 \ifnum`#1>"DF
280 (((`#1-"E0)%
281 \else
282 \ifnum`#1>"BF
283 ((`#1-"C0)%
284 \else
285 \ifnum`#1>"7F
286 )*64+(`#1-"80)%
287 \else
288 +`#1 %
289 \fi
290 \fi
291 \fi
292 \fi
293 \expandafter\dec@de@UTFviii
294 \fi}
295 \fi
296 \ifx\numexpr\@undefined
297 \global\let\UTFviii@hexnumber\@firstofone
298 \global\UTFviii@hexdigit\hexnumber@
299 \else
300 \gdef\UTFviii@hexnumber#1{%
301 \ifnum#1>15 %
302 \expandafter\UTFviii@hexnumber\expandafter{\the\numexpr(#1-8)/16\relax}%
303 \fi
304 \UTFviii@hexdigit{\numexpr#1\ifnum#1>0-((#1-8)/16)*16\fi\relax}%
305 }
306 \gdef\UTFviii@hexdigit#1{\ifcase\numexpr#1\relax
307 0\or1\or2\or3\or4\or5\or6\or7\or8\or9\or
308 A\or B\or C\or D\or E\or F\fi}
309 \fi
310 \gdef\UTFviii@hexcodepoint#1{U+%
311 \ifnum#1<16 0\fi
312 \ifnum#1<256 0\fi
313 \ifnum#1<4096 0\fi
314 \UTFviii@hexnumber{#1}%
315 }%
316 \gdef\UTFviii@splitcsname#1:#2\relax{%
317 #2 (\expandafter\UTFviii@hexcodepoint\expandafter{%
318 \the\numexpr\decode@UTFviii#2\relax})%
319 }
320 \endgroup
321 \@onlypreamble\DeclareUnicodeCharacter
322 \@onlypreamble\parse@XML@charref
323 \@onlypreamble\parse@UTFviii@a
324 \@onlypreamble\parse@UTFviii@b
325 \begingroup
326 \def\cdp@elt#1#2#3#4{%
327 \wlog{Now handling font encoding #1 ...}%
328 \lowercase{%
329 \InputIfFileExists{#1enc.dfu}}%
330 {\wlog{... processing UTF-8 mapping file for font %
331 encoding #1}%
332 \catcode`\ 9\relax}%
333 {\wlog{... no UTF-8 mapping file for font encoding #1}}%
334 }
335 \cdp@list
336 \endgroup
337 \def\DeclareFontEncoding@#1#2#3{%
338 \expandafter
339 \ifx\csname T@#1\endcsname\relax
340 \def\cdp@elt{\noexpand\cdp@elt}%
341 \xdef\cdp@list{\cdp@list\cdp@elt{#1}%
342 {\default@family}{\default@series}%
343 {\default@shape}}%
344 \expandafter\let\csname#1-cmd\endcsname\@changed@cmd
345 \begingroup
346 \wlog{Now handling font encoding #1 ...}%
347 \lowercase{%
348 \InputIfFileExists{#1enc.dfu}}%
349 {\wlog{... processing UTF-8 mapping file for font %
350 encoding #1}}%
351 {\wlog{... no UTF-8 mapping file for font encoding #1}}%
352 \endgroup
353 \else
354 \@font@info{Redeclaring font encoding #1}%
355 \fi
356 \global\@namedef{T@#1}{#2}%
357 \global\@namedef{M@#1}{\default@M#3}%
358 \xdef\LastDeclaredEncoding{#1}%
359 }
360 \DeclareUnicodeCharacter{00A9}{\textcopyright}
361 \DeclareUnicodeCharacter{00AA}{\textordfeminine}
362 \DeclareUnicodeCharacter{00AE}{\textregistered}
363 \DeclareUnicodeCharacter{00BA}{\textordmasculine}
364 \DeclareUnicodeCharacter{02C6}{\textasciicircum}
365 \DeclareUnicodeCharacter{02DC}{\textasciitilde}
366 \DeclareUnicodeCharacter{200C}{\textcompwordmark}
367 \DeclareUnicodeCharacter{2026}{\textellipsis}
368 \DeclareUnicodeCharacter{2122}{\texttrademark}
369 \DeclareUnicodeCharacter{2423}{\textvisiblespace}
370 \DeclareUnicodeCharacter{FEFF}{\ifhmode\nobreak\fi}
371 \endinput
372 %%
373 %% End of file `utf8.def'.