summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ucs/ucs.sty
blob: 57b6f50eddb72321744a878ee62fa27e2e391026 (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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
%%
%% This is file `ucs.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ucs.dtx  (with options: `ucs.sty')
%% 
%% Copyright 2001 Dominique Unruh  <unruh@ut.ee>
%% Copyright 2012 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.
%% 
\catcode`\@11
\ifx\@gobble\undefined\def\@gobble#1{}\fi
\ifx\@gobbletwo\undefined\def\@gobbletwo#1#2{}\fi
\ifx\@gobblethree\undefined\def\@gobblethree#1#2#3{}\fi
\ifx\@gobblefour\undefined\def\@gobblefour#1#2#3#4{}\fi
\ifx\@firstofone\undefined\def\@firstofone#1{#1}\fi
\ifx\@tempcnta\undefined\csname newcount\endcsname\@tempcnta\fi
\ifx\@tempcntb\undefined\csname newcount\endcsname\@tempcntb\fi
\ifx\@testopt\undefined
  \def\@testopt#1#2{%
    \@ifnextchar[{#1}{#1[{#2}]}}\fi
\ifx\@protected@testopt\undefined\def\@protected@testopt{\expandafter\@testopt\@gobble}\fi
\ifx\@ifnextchar\undefined
  \def\@ifnextchar#1#2#3{%
    \let\reserved@d=#1%
    \def\reserved@a{#2}%
    \def\reserved@b{#3}%
    \futurelet\@let@token\@ifnch}\fi
\ifx\@ifnch\undefined
  \def\@ifnch{%
    \ifx\@let@token\@sptoken
      \let\reserved@c\@xifnch
    \else
      \ifx\@let@token\reserved@d
        \let\reserved@c\reserved@a
      \else
        \let\reserved@c\reserved@b
      \fi
    \fi
    \reserved@c}\fi
\ifx\@inputcheck\undefined\newread\@inputcheck\fi
\ifx\IfFileExists\undefined
\long\def\IfFileExists#1#2#3{%
  \openin\@inputcheck#1 %SPACE
  \ifeof\@inputcheck\def\reserved@a{#3}%
  \else\closein\@inputcheck\def\reserved@a{#2}%
  \fi
  \reserved@a}%
\fi
\ifx\InputIfFileExists\undefined
\long\def\InputIfFileExists#1#2{%
  \IfFileExists{#1}{#2\input #1 }}
\fi
\ifx\protect\undefined\let\protect\relax\fi
\ifx\@typeset@protect\undefined\let\@typeset@protect\relax\fi
\ifx\IeC\undefined\def\IeC{\ifx\protect\@typeset@protect
  \expandafter\@firstofone\else\noexpand\IeC\fi}\fi
\def\unicode@knownoptions{}
\def\XDeclareUnicodeOption#1#2#3#4#5{%
  \expandafter\let\csname ifUnicodeOption#2\endcsname\iffalse
  \expandafter\def\csname UnicodeOption#2true%
    \expandafter\endcsname\expandafter{%
      \expandafter\let\csname ifUnicodeOption#2\endcsname\iftrue}%
  \expandafter\def\csname UnicodeOption#2false%
    \expandafter\endcsname\expandafter{%
      \expandafter\let\csname ifUnicodeOption#2\endcsname\iffalse}%
  \expandafter\def\csname @unicode@option@#2\endcsname{%
    #3\uni@activate@option{#2}{}{#4}{#5}}%
  \expandafter\def\csname @unicode@option@no#2\endcsname{%
    #3\uni@activate@option{#2}{no}{#4}{#5}}%
  \ifx~#1~\else\LinkUnicodeOptionToPkg{#2}{#1}\fi
  \let\uc@tempa\\\let\\\relax
  \edef\unicode@knownoptions{\\{#2}\unicode@knownoptions}%
  \let\\\uc@tempa
  }%
\let\uc@newcommand\def
\uc@newcommand\DeclareUnicodeOption{\@protected@testopt\DeclareUnicodeOption\DeclareUnicodeOption@{}}
\uc@newcommand\DeclareUnicodeOption@[#1]#2{%
  \XDeclareUnicodeOption{#1}{#2}{}{}{}}%
\uc@newcommand\uc@errormsg#1#2{%
  \ifx\PackageError\undefined
    {\newlinechar`\^^J\def\MessageBreak{^^J}%
      \errhelp{#2}\errmessage{Package ucs: #1}}%
  \else
    \PackageError{ucs}{#1}{#2}%
  \fi
}%
\uc@newcommand\uc@warnmsg#1{%
  \ifx\PackageWarning\undefined
    {\newlinechar`\^^J\def\MessageBreak{^^J}%
      \message{Package ucs: #1\MessageBreak}}%
  \else
    \PackageWarning{ucs}{#1}%
  \fi
}%
\def\uni@activate@option#1#2#3#4#5{%
  \ifx\uni@dataloaded\undefined
  \global\expandafter\def\csname @unicode@option@#1\endcsname##1{%
    \csname UnicodeOption#1true\endcsname
    \expandafter\def\csname uo-prio-#1\endcsname{##1}#3}%
  \global\expandafter\def\csname @unicode@option@no#1\endcsname##1%
    {\csname UnicodeOption#1false\endcsname#4}%
  \global\expandafter\let\csname uni@active@#1\endcsname1%
  \csname @unicode@option@#2#1\endcsname{#5}\else
  \uc@errormsg{Option #1 must be activated or deactivated %SPACE
    at least once in the preamble before using it in the document}{%
    For optimization causes I must know all %SPACE
    options before loading any unicode data.\MessageBreak
    Try e.g. #1 or no#1 as package option to ucs.}\fi}
\def\LinkUnicodeOptionToPkg#1#2{%
  \AtBeginDocument{\@ifpackageloaded{#2}{\SetUnicodeOption{#1}}{}}}%
\uc@newcommand\SetUnicodeOption{\@protected@testopt\SetUnicodeOption\SetUnicodeOption@{100}}
\uc@newcommand\SetUnicodeOption@[#1]#2{%
  \edef\uc@temp@a{@unicode@option@#2}%
  \expandafter\ifx\csname\uc@temp@a\endcsname\relax
    \PackageError{ucs}{Unknown unicode option #2}{}%
  \else
    \csname\uc@temp@a\endcsname{#1}%
  \fi}
\ifx\ProvidesPackage\undefined\else
\ProvidesPackage{ucs}[2004/10/17 UCS: Unicode input support]%
\fi
\ifx\@@input\undefined\input uni-global.def \else\input{uni-global.def}\fi
\DeclareUnicodeOption{fasterrors}
\DeclareUnicodeOption{warnunknown}
\DeclareUnicodeOption{graphics}
\DeclareUnicodeOption{savemem}
\DeclareUnicodeOption{document}
\SetUnicodeOption[1000]{document}
\DeclareUnicodeOption{default}
\SetUnicodeOption[0]{default}
\XDeclareUnicodeOption{}{combine}{}{%
  \let\uc@cmb\empty}{%
  \ifx\unicodecombine\undefined\else\unicodecombine\fi
  \def\uc@cmb{\uc@warn@nocombine}}%
\ifx\AtBeginDocument\undefined\else
  \AtEndDocument{\unicodecombine}\fi
\SetUnicodeOption{nocombine}%
\def\uc@cmb{\uc@warn@nocombine}%
\ifx\DeclareOption\undefined\else
\DeclareOption{showmagickern}{\def\uc@magic@glue{6805678}}%
\DeclareOption{hyperref}{\AtEndOfPackage{\RequirePackage{ucshyper}}}%
\DeclareOption*{\SetUnicodeOption{\CurrentOption}}\ProcessOptions*
\fi
\ifx\AtBeginDocument\undefined
  \uc@warnmsg{Not loading ucsencs.def automatically.\MessageBreak
    Please load it after initializing fontencodings}%
\else
  \AtBeginDocument{\input{ucsencs.def}}\fi
\AtBeginDocument{\ifUnicodeOptiongraphics\RequirePackage{graphicx}\fi}%
\uc@newcommand\unicode@numtohex{\protect\unicode@numtohex@}%
\uc@newcommand\unicode@numtohex@#1#2#3{%
  {%\let\empty\relax\relax
   %\ifx\empty\relax\def\empty{}%
     \count255=#2\relax\gdef#1{}%
     \count252=#3%
     \loop
     \count253=\count252\advance\count253by\count255\relax
     \ifnum\count253>0%
     \ifnum\count252>0\advance\count252by-1\relax\fi
     \count254=\count255%
     \divide\count255by16%
     \multiply\count255by16%
     \advance\count254by-\count255%
     \xdef#1{\ifcase\count254 0\or1\or2\or3\or4\or5\or6\or7\or
       8\or9\or A\or B\or C\or D\or E\or F\fi#1}%
     \divide\count255by16\relax
     \repeat
   %\else
   %  \def#1{dec:#2}%
   %\fi
   }}
\let\uc@spc\space
\newcount\uc@secondtry
\uc@newcommand\unicode@invalid#1{%
  \unicode@combine%
  \ifUnicodeOptiongraphics{%
  \ifx\unicode@graphicsdir\undefined
    \def\unicode@graphicsdir{ucs-glyphs}\fi
  \ifx\unicode@graphicscmd\undefined
    \def\unicode@graphicscmd{ucs-getglyph \hex\space \dec\space \path\space}\fi
  \unicode@numtohex\hex{#1}4%
  \count255=#1\relax
  \divide\count255 by256\relax
  \unicode@numtohex\uc@temp@b{\count255}2%
  \edef\path{\unicode@graphicsdir/\uc@temp@b/U\hex.ps}%
  \edef\dec{\number#1}%
  \IfFileExists{\uc@temp@c}{}{%
    \typeout{Running: \unicode@graphicscmd}%
    \immediate\write18{\unicode@graphicscmd}%
    }%
 \IfFileExists{\path}{%
    \setbox255=\hbox{X}%
    \edef\uc@temp@b{\begingroup\noexpand\uni@resetcatcodes
      \noexpand\includegraphics[height=\the\ht255, trim=0 22.5 0 17.5]%
                      {\path}%
    \noexpand\ProvidesFile{U\hex.ps}%
        [Downloaded glyph for U+\hex]%
    \endgroup}%
  \typeout{\meaning\uc@temp@b}%
  \expandafter\unicodevirtual\expandafter{\uc@temp@b}%
  }{%
    \PackageWarning{ucs}{File \uc@temp@d\uc@temp@c.ps %SPACE
      not found.\MessageBreak
      Use\MessageBreak
      \space\space\space\space\unicode@graphicscmd\MessageBreak
      or start latex with option -shell-escape\MessageBreak
      if you have not already done so.}%
    \unicodevirtual{\unicode@invalidglyph{#1}}}}\else
    \unicodevirtual{\unicode@invalidglyph{#1}}\fi}
\uc@newcommand\unicode@invalidglyph#1{%
  {\unicode@numtohex\uc@temp@d{#1}4%
    \fontencoding{OT1}\texttt{[U+\uc@temp@d]}}}
\uc@newcommand\uni@char#1{%
  \ucs@protected@unichar\iftrue
    \expandafter\ifx\csname u-\number#1-h/o\endcsname\relax
  %    \end{macrocode}
  % If the character is not defined yet, load it.
  %    \begin{macrocode}
      \begingroup
        % In case \let is not executed, this (until ===) expands
        % to \let\relax\relax,
        % otherwise we have \let\uc@notloaderr\@gobble
        % Number of \empty's must equal number of args of \uc@char@notloaded
        \let\uc@notloaderr\@gobble\empty\@gobbletwo\relax\relax
        % ===
      \expandafter\endgroup
      % If \let not executed: Warning is emitted (see |\uc@notloaderr|)
      % otherwise: |\uc@char@notloaded| is called.
      \uc@notloaderr{\number#1}\uc@char@notloaded{#1}%
    \else
  %    \end{macrocode}
  % If the character is loaded, run |\uc@checkopts|
  % with the options of this character
  % as first arg and the code position as second; this will
  % display the character with
  % the correct option.
  %    \begin{macrocode}
     \expandafter\expandafter\expandafter\uc@checkopts
       \expandafter\expandafter\expandafter
       {\csname u-\number#1-h/o\endcsname}{#1}%
    \fi
  \else
    \noexpand\unichar{#1}%
  \fi
}
\begingroup
  \lccode`\A=`\{\lccode`\B=`\}\lccode`\C=`\\%
  \lccode`\P=`\P\lccode`\U=`\U%
  \lowercase{%
\endgroup
  \uc@newcommand\uc@notloaderr#1#2#3{%
    \ifx\@gobble#1\else[Please insert %SPACE
      CPrerenderUnicodeACunicharA#1BB into preamble]\fi}}
\uc@newcommand\uc@checkopts#1#2{%
  \expandafter\uc@checkopt@error\expandafter{\number#2}%
    {error}{error}{infinity}#1\@nil
}
\expandafter\uc@newcommand\csname uo-prio-infinity\endcsname{-2100000000}
%% === BEGIN AUTOGENERATED CODE
\uc@newcommand\uc@checkopt@stick#1#2#3#4#5{%
  \ifx\@nil#5%
\expandafter\ifx\csname u-#2-#1\endcsname\relax
  \uc@localdeferr{#1}{#2}%
\else
  \uc@output{\csname u-#2-#1\endcsname}{#1}%
\fi
    \expandafter\@gobblefour
  \else
    \iftrue\csname fi\endcsname
    \csname ifUnicodeOption#5\endcsname
      \ifnum\csname uo-prio-#2\endcsname>\csname uo-prio-#5\endcsname\uc@spc
        \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
        \uc@checkopt@stick
      \else
        \ifnum\csname uo-prio-#2\endcsname<\csname uo-prio-#5\endcsname\uc@spc
          \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
          \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
          \uc@checkopt@change
        \else
          \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
          \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
          \uc@checkopt@error
        \fi
      \fi
    \else
      \expandafter\expandafter\expandafter\uc@checkopt@stick
    \fi
  \fi
  {#1}{#2}{#5}{#2}%
}
\uc@newcommand\uc@checkopt@change#1#2#3#4#5{%
  \ifx\@nil#5%
\expandafter\ifx\csname u-#3-#1\endcsname\relax
  \uc@localdeferr{#1}{#3}%
\else
  \uc@output{\csname u-#3-#1\endcsname}{#1}%
\fi
    \expandafter\@gobblefour
  \else
    \iftrue\csname fi\endcsname
    \csname ifUnicodeOption#5\endcsname
      \ifnum\csname uo-prio-#3\endcsname>\csname uo-prio-#5\endcsname\uc@spc
        \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
        \uc@checkopt@stick
      \else
        \ifnum\csname uo-prio-#3\endcsname<\csname uo-prio-#5\endcsname\uc@spc
          \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
          \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
          \uc@checkopt@change
        \else
          \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
          \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
          \uc@checkopt@error
        \fi
      \fi
    \else
      \expandafter\expandafter\expandafter\uc@checkopt@stick
    \fi
  \fi
  {#1}{#3}{#5}{#3}%
}
\uc@newcommand\uc@checkopt@error#1#2#3#4#5{%
  \ifx\@nil#5%
\uc@errordrawopt{#1}{#2, #3}{#4}%
    \expandafter\@gobblefour
  \else
    \iftrue\csname fi\endcsname
    \csname ifUnicodeOption#5\endcsname
      \ifnum\csname uo-prio-#4\endcsname>\csname uo-prio-#5\endcsname\uc@spc
        \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
        \uc@checkopt@errorstick
      \else
        \ifnum\csname uo-prio-#4\endcsname<\csname uo-prio-#5\endcsname\uc@spc
          \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
          \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
          \uc@checkopt@change
        \else
          \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
          \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
          \uc@checkopt@error
        \fi
      \fi
    \else
      \expandafter\expandafter\expandafter\uc@checkopt@errorstick
    \fi
  \fi
  {#1}{#2, #3}{#5}{#4}%
}
\uc@newcommand\uc@checkopt@errorstick#1#2#3#4#5{%
  \ifx\@nil#5%
\uc@errordrawopt{#1}{#2}{#4}%
    \expandafter\@gobblefour
  \else
    \iftrue\csname fi\endcsname
    \csname ifUnicodeOption#5\endcsname
      \ifnum\csname uo-prio-#4\endcsname>\csname uo-prio-#5\endcsname\uc@spc
        \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
        \uc@checkopt@errorstick
      \else
        \ifnum\csname uo-prio-#4\endcsname<\csname uo-prio-#5\endcsname\uc@spc
          \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
          \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
          \uc@checkopt@change
        \else
          \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
          \expandafter\expandafter\expandafter\expandafter\expandafter\expandafter\expandafter
          \uc@checkopt@error
        \fi
      \fi
    \else
      \expandafter\expandafter\expandafter\uc@checkopt@errorstick
    \fi
  \fi
  {#1}{#2}{#5}{#4}%
}
\let\unicode@empty\empty
\uc@newcommand\uc@errordrawopt#1#2#3{%
  \let\unicode@empty\relax\relax
  \ifx\unicode@empty\relax\let\unicode@empty\empty
    \unicode@numtohex\uc@temp@b{#1}4%
    \ifnum\csname uo-prio-#3\endcsname=-2100000000\relax
      \expandafter\ifx\csname
        missing-unicode-warned-\number#1\endcsname\relax
        \global\expandafter\let\csname
          missing-unicode-warned-\number#1\endcsname\@ne
        \unicode@error@unknown\@ne{Character \number#1\uc@spc
          \uc@spc= U+\uc@temp@b\uc@spc
          matches no activated options.\MessageBreak
          Type H to see available options}{#1}%
      \else
        \PackageWarning{ucs}{Character % SPACE
          \number#1 \uc@spc= 0x\uc@temp@b\uc@spc
          appeared again.}%
      \fi
    \else
      \@getcharinfo\uc@temp@c{#1}%
      \PackageWarning{ucs}{Character %SPACE
        \number#1 \uc@spc= 0x\uc@temp@b\uc@spc
        matches options\MessageBreak
        \uc@spc\uc@spc\uc@spc#2\MessageBreak
        with same priority \csname uo-prio-#3\endcsname. %SPACE
        Selecting option #3.\MessageBreak
        \uc@temp@c}%
      \uc@output{\csname u-#3-#1\endcsname}{#1}%
    \fi
  \else
    \noexpand\unichar{#1}%
  \fi
}
\uc@newcommand\uc@output#1#2{%
  \ifx\unicode@delay1\let\unicode@delay\relax\else
    \ifUnicodeOptioncombine
      \expandafter\uc@combine\expandafter{#1}{#2}%
    \else
      \uc@prechar@exec{#2}%
        \unicode@charfilter{#1{}}%
    \fi
    \ifx\uc@throw\undefined\else
      \def\uc@got{#2}\uc@throw\global\let\uc@throw\undefined\fi
  \fi
}%
\uc@newcommand\uc@prechar@exec#1{%
  \ifx\uc@prechar\undefined\else\uc@prechar{#1}\fi}
\uc@newcommand\uc@localdeferr#1#2{%
  \@getcharinfo\uc@temp@a{#1}%
  \PackageError{ucs}{Internal error in character \number#1, %SPACE
    option #2}{I probably got confused by intermixed local %SPACE
    and global definitions.\MessageBreak Try to load the needed %SPACE
    code page via \noexpand\PreloadUnicodePage
    before declaring anything by yourself.}{\uc@temp@a}%
  \unicode@invalid{#1}%
}%
\uc@newcommand\uc@warn@nocombine{%
  \PackageError{ucs}{Please activate option 'combine'}{Composed %SPACE
    characters can only be rendered correctly, when the option %SPACE
    'combine' is activated}}
\newtoks\uc@combtoks
\newtoks\uc@combtoksb
\newtoks\uc@temptokena
\uc@newcommand\unicode@combine{%
  \uc@check@magicglue%
  \ifx\uc@combining@prechar\undefined\global\let\uc@comb@code\undefined\fi
  \ifx\uc@comb@code\undefined\uc@temptokena{}\else
    \uc@temptokena\expandafter{\expandafter\uc@prechar@exec
      \expandafter{\uc@comb@code}}\fi%
  \global\let\uc@comb@code\undefined
  \global\expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\uc@combtoksb
  \expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter{%
    \expandafter\expandafter\expandafter\the
    \expandafter\expandafter\expandafter\uc@combtoksb
    \expandafter\the\expandafter\uc@temptokena\the\uc@combtoks}%
  \global\uc@combtoks{}}
\def\uc@magic@glue{5381}
\uc@newcommand\uc@check@magicglue{%
  \ifnum\lastskip=\uc@magic@glue\unskip\else
    \begingroup
      \edef\uc@temp@a{\the\uc@combtoks}%
      \ifx\uc@temp@a\empty\else
      \PackageWarning{ucs}{Magic kern expected. Probably some %SPACE
        non-unicode characters mixed in while option combine was %SPACE
        in effect.}\fi\endgroup
  \fi}
\uc@newcommand\unicodevirtual#1{%
  \def\uc@temp@a##1{#1}\uc@output{\csname uc@temp@a\endcsname}{"FFFF}}
\uc@newcommand\unicodecombine{%
  \ifx\protect\@typeset@protect
    \unicode@combine%
    %\typeout{WRITING: \the\uc@combtoksb}%
    \the\uc@combtoksb
    \uc@prechar@exec{-1}%
    \global\uc@combtoksb{}%
      \ifx\uc@throw\undefined\else
        \def\uc@got{-1}\uc@throw\global\let\uc@throw\undefined\fi
  \else
    \noexpand\unicodecombine\fi
}
\uc@newcommand\uc@combine#1#2{%
  \ifx\protect\@typeset@protect
    \@temptokena\expandafter{#1{}}%
    \expandafter\expandafter\expandafter\ifx
    \expandafter\uc@firstofmany\the\@temptokena\uc@firstofmany\uc@cmb
      \uc@check@magicglue%
      \uc@combtoks\expandafter\expandafter\expandafter\expandafter
     \expandafter\expandafter\expandafter{%
        \expandafter\expandafter\expandafter\@gobble
        \expandafter#1\expandafter{\the\uc@combtoks}}%
    \else
      \unicode@combine%
      \xdef\uc@comb@code{\number#2}%
      \global\uc@combtoks\expandafter{#1{}}%
    \fi
    %\typeout{->COMBTOKS: \the\uc@combtoks}%
    \hskip\uc@magic@glue spplus0ptminus0pt %SPACE ; Insert magic glue
  \else
    \noexpand\unichar{\number#2}\fi
}
\uc@newcommand\uc@char@notloaded#1{%
  \count255=#1\divide\count255 by 256%
  \edef\uc@temp@a{uni-\number\count255.def}%
  \expandafter\ifx\csname\uc@temp@a\endcsname\relax\else
    \uc@secondtry#1\relax\fi
  \ifnum\uc@secondtry=#1\relax
    % If the file has already been loaded, but the character is unknown,
    % output an error and show the replacement glyph
    \unicode@numtohex\uc@temp@b{#1}4%
    \expandafter\ifx\csname
      missing-unicode-warned-\number#1\endcsname\relax
    \global\expandafter\let\csname
      missing-unicode-warned-\number#1\endcsname\@ne
      \unicode@error@unknown\@ne{Unknown Unicode character % SPACE
        \number#1 \uc@spc= U+\uc@temp@b,\MessageBreak
        possibly declared in \uc@temp@a.\MessageBreak
        Type H to see if it is available with options}{#1}%
    \else
      \PackageWarning{ucs}{Unknown character % SPACE
        \number#1 \uc@spc = 0x\uc@temp@b\uc@spc
        appeared again.}%
      \unicode@invalid{#1}%
    \fi
  \else
    \begingroup
    \ifUnicodeOptionsavemem
    \else
      \global\expandafter\let\csname\uc@temp@a\endcsname\@ne
    \fi
    \def\uc@got{#1}%
    \uni@resetcatcodes
    \expandafter\InputIfFileExists\expandafter{\uc@temp@a}{%
      \global\let\uni@dataloaded1%
      }{%
      }%
      % End of local group for inputted file
    \endgroup
      % Retry displaying character. This won't cause infinite recursion,
      % because we have marked this file as loaded (globally or, if
      % |savemem| is set, at least here).
    \uc@secondtry#1\relax%
    \uni@char{#1}%
  \fi
  }
\uc@newcommand\PreloadUnicodePage#1{%
  \begingroup
  \global\expandafter\let\csname uni-#1.def\endcsname\@ne
  \uni@resetcatcodes
  \InputIfFileExists{uni-#1.def}{\let\uni@dataloaded1}{%
    \PackageError{ucs}{Could not find uni-#1.def}{}}%
  \endgroup}
\uc@newcommand\PrerenderUnicode{%
  \@ifstar{\@prerenderunicode\unichar}{\@prerenderunicode\@gobble}}%
\uc@newcommand\@prerenderunicode#1#2{%
  \begingroup
  \UnicodeCharFilter\@gobble
  \let#1\@gobble\setbox0\hbox{#2}\endgroup}
\uc@newcommand\DeclareUnicodeCharacter#1#2{%
  \DeclareUnicodeCharacterAsOptional{#1}{document}{#2}}
\uc@newcommand\DeclareUnicodeCharacterAsOptional{%
  \let\uc@temp@a\relax\uni@declcharopt}
\uc@newcommand\uc@dclc#1#2{%
  \let\next=\uni@declcharopt
  \ifUnicodeOptionsavemem
    \ifnum\uc@got=#1\else
      \let\next=\@gobblethree\fi
  \fi
  \ifx\next\uni@declcharopt
    \expandafter\ifx\csname uni@active@#2\endcsname\relax
      \let\next\@gobblethree\else
    \expandafter\ifx\csname u-#2-\number#1\endcsname\relax\else
      \let\next\@gobblethree\fi\fi
    \let\uc@temp@a\global
  \fi
  \next{#1}{#2}}
\uc@newcommand\uni@declcharopt#1#2#3{%
  %\typeout{Defining: u-#2-\number#1 (\meaning\uc@temp@a)}%
  \ifx\utf@viii@map\undefined\else
    \expandafter\utf@viii@map\expandafter{\number#1}\fi
  \expandafter\uc@temp@a\expandafter\def
    \csname u-#2-\number#1\endcsname##1{#3}%\fi
  \expandafter\ifx\csname u-\number#1-h/o\endcsname\relax
    \expandafter\def\csname u-\number#1-h/o\endcsname{}\fi
  \expandafter\uc@temp@a\expandafter\edef
    \csname u-\number#1-h/o\endcsname{%
    {#2}\csname u-\number#1-h/o\endcsname}%
  }%
\let\unichar\uni@char
\uc@newcommand\unicodesuper#1{\textsuperscript{#1}}%
\uc@newcommand\@getcharinfo#1#2{%
  \begingroup
  \countdef\uc@got0\relax\uc@got#2\relax
  \global\def#1{Character's name unknown}%
  \def\info##1{\xdef#1{##1}}%
  \uni@resetcatcodes
  \ifUnicodeOptionfasterrors
  \global\def#1{No further informations known % SPACE
    because of option fasterrors.}\else
  {\InputIfFileExists{uninames.dat}{}{%
    \global\def#1{Character database uninames.dat not found. %SPACE
      \MessageBreak Character \number#2 \uc@spc unknown}}}%
  \fi
  \toks255{}%
  \def\uc@dclc##1##2##3{\ifnum##1=\uc@got
    \toks255\expandafter{\the\toks255, ##2}\fi}%
  \count255\uc@got\divide\count255by256\relax
  %\edef\temp@a{uni-\number\count255.def}%
  \InputIfFileExists{uni-\number\count255.def}{}{}%
  \expandafter\ifx\expandafter\@nil\the\toks255 \@nil
    \xdef#1{#1\noexpand\MessageBreak
      Character is not defined in uni-*.def files}%
  \else
    \expandafter\expandafter\expandafter\@getcharinfo@
    \expandafter\expandafter\expandafter#1%
    \expandafter\expandafter\expandafter
    {\expandafter#1\expandafter}\the\toks255 \@nil%
  \fi
  \endgroup}
\def\@getcharinfo@#1#2, #3\@nil{\gdef#1{#2\MessageBreak
    Character available with following options:\MessageBreak
    \uc@spc\uc@spc\uc@spc #3}}
\uc@newcommand\PrintUnicodeName#1{{%
  \@getcharinfo{\ci}{#1}%
  \def\MessageBreak{^^J}%
  \typeout{^^J\ci^^J}}}
\uc@newcommand\UnicodeCharFilter#1{\let\unicode@charfilter=#1}
\uc@newcommand\UCSProtectionNone{%
  \def\ucs@protected@unichar{}%
  \UnicodeCharFilter\@firstofone}
\uc@newcommand\UCSProtectionIeC{%
  \def\ucs@protected@unichar{}%
  \UnicodeCharFilter\IeC}
\uc@newcommand\UCSProtectionUnichar{%
  \def\ucs@protected@unichar##1{\ifx\protect\@typeset@protect}%
  \UnicodeCharFilter\@firstofone}
\UCSProtectionIeC
\uc@newcommand\uni@resetcatcodes{%
  \endlinechar=13\relax
  \def\reserved@a##1##2{%
    \@tempcnta##1\relax
    \@tempcntb##2\relax
    \reserved@b
    }%
  \def\reserved@b{%
    \ifnum\@tempcnta>\@tempcntb\else
    \reserved@c\@tempcnta
    \advance\@tempcnta\@ne
    \expandafter\reserved@b
    \fi
    }%
  \catcode`\ =10\relax
  \catcode`\#=6\relax
  \catcode`\$=3\relax
  \catcode`\%=14\relax
  \catcode`\&=4\relax
  \catcode`\\=0\relax
  \catcode`\^=7\relax
  \catcode`\_=8\relax
  \catcode`\{=1\relax
  \catcode`\}=2\relax
  \catcode`\~=13\relax
  \catcode`\@=11\relax
  \catcode`\^^I=10\relax
  \catcode`\^^J=12\relax
  \catcode`\^^L=12\relax
  \catcode`\^^M=5\relax
  \def\reserved@c##1{\catcode##1=12\relax}%
  \reserved@c{`\!}%
  \reserved@c{`\"}%
  \reserved@a{`\'}{`\?}%
  \reserved@c{`\[}%
  \reserved@c{`\]}%
  \reserved@c{`\`}%
  \reserved@c{`\|}%
  \def\reserved@c##1{\catcode##1=11\relax}%
  \reserved@a{`\A}{`\Z}%
  \reserved@a{`\a}{`\z}%
  \def\reserved@c##1{\catcode##1=15\relax}%
  \reserved@a{0}{`\^^H}%
  \reserved@c{`\^^K}%
  \reserved@a{`\^^N}{31}%
  \catcode"7F=15\relax
  \relax}
\catcode`\!13\relax
\uc@newcommand\unicode@error@unknown{\protect\unicode@error@unknown@}%
\uc@newcommand\unicode@error@unknown@#1#2#3{%
  {\expandafter\countdef\expandafter\uc@got\expandafter0%
     \expandafter\relax\expandafter\uc@got\number#3\relax
  \ifx\measuring@false\undefined\else\measuring@false\fi
  \@getcharinfo\uc@temp@c{#3}%
  \ifUnicodeOptionwarnunknown
    \PackageWarning{ucs}{#2\MessageBreak\uc@temp@c.\MessageBreak
        Enter I\noexpand!<RET> to define the glyph.}%
    \ifx#1\@ne\unicode@invalid{#3}\fi
  \else
    \let!\unicode@read@definition\catcode`\!13\relax
    \let\uc@read@definition\undefined
    \PackageError{ucs}{#2}{\uc@temp@c.\MessageBreak
        Enter I\noexpand!<RET> to define the glyph.}%
    \ifx#1\@ne
    \ifx\uc@read@definition\undefined\unicode@invalid{#3}%
    \else\uc@read@definition\fi\fi
  \fi}}
\catcode`\!12\relax
\uc@newcommand\unicode@read@definition{%
  \uni@resetcatcodes
  \typein[\definition]{Please enter definition for %SPACE
    unicode character \number\uc@got}%
  \global\let\uc@read@definition\definition
  \toks255\expandafter{\definition}%
  \edef\definition{\noexpand\DeclareUnicodeCharacter%
    {\number\uc@got}{\the\toks255}}%
  \toks255\expandafter{\definition}%
  \typeout{Tip:\MessageBreak You may include\MessageBreak
    \uc@spc\uc@spc\the\toks255\MessageBreak
    into your document source.}%
  \the\toks255\relax
  }
\def\uc@firstofmany#1#2\uc@firstofmany{#1}
\ifx\AtBeginDocument\undefined\else
\AtBeginDocument{\def\uc@tempa{\@inpenc@undefined@{utf8}}%
  \ifx\@inpenc@undefined\uc@tempa
  \ifx\restore@utf@viii@actives\undefined
  \PackageWarning{ucs}{***************************\MessageBreak You %SPACE
    seem to have loaded inputencoding utf8\MessageBreak (LaTeX kernel %SPACE
    UTF-8) instead of utf8x (ucs.sty UTF-8).\MessageBreak Probably you %SPACE
    are compiling a document written for a\MessageBreak
    pre-august-2004 ucs.sty.\MessageBreak
    ***************************\MessageBreak Please use %SPACE
    \string\usepackage[utf8x]{inputenc} instead of\MessageBreak
    \string\usepackage[utf8]{inputenc}.\MessageBreak
    ***************************\MessageBreak If you should really want %SPACE
    to use ucs.sty and kernel's\MessageBreak utf8.def together, use %SPACE
    \string\usepackage[utf8x,utf8]{inputenc}\MessageBreak to disable %SPACE
    compatibility mode\MessageBreak
    ***************************\MessageBreak Activating compatibility %SPACE
    mode.\MessageBreak ***************************\MessageBreak}%
  \global\let\uc@inputencoding\inputencoding
  \inputencoding{utf8x}%
  \def\inputencoding#1{%
    {\def\uc@tempa{#1}\def\uc@tempb{utf8}\ifx\uc@tempa\uc@tempb
      \aftergroup\@firstoftwo\else\aftergroup\@secondoftwo\fi}%
    {\restore@utf@viii@actives}{\uc@inputencoding{#1}}}%
  \fi\fi
}\fi