summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/ucs/ucsutils.sty
blob: e9ac6503fec25750b2b030aaa0c76977a429588c (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
%%
%% This is file `ucsutils.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ucs.dtx  (with options: `ucsutils.sty')
%% 
%% 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\DeclareOption\undefined\else
\ProvidesPackage{ucsutils}[2002/04/23 UCS: Auxiliary macros]%
\RequirePackage{ucs}%
\ifx\@ucsutils\undefined\let\@ucsutils\empty\fi
\DeclareOption*{%
  \edef\uc@temp@a{\csname\CurrentOption\endcsname}%
  \expandafter\g@addto@macro\expandafter\@ucsutils\expandafter
  {\expandafter\\\uc@temp@a}}%
\ProcessOptions*%
\fi
{\def\\#1{\ifx#1\relax\global\let#11\fi}\@ucsutils}%
\def\@ucsutils@section#1{\ifx#11\catcode2=9\else\catcode2=14\fi\relax}%
\@ucsutils@section\UnicodeEmbedFont
^^B\RequirePackage{keyval}%
^^B\def\UnicodeEmbedFont#1{%
^^B  \ifx\KV@ucembedfont@start\undefined
^^B    \define@key{ucembedfont}{encoding}{\def\uc@embedfont@enc{##1}}%
^^B    \define@key{ucembedfont}{start}{\def\uc@embedfont@start{##1}}%
^^B    \define@key{ucembedfont}{fontstart}%
^^B               {\def\uc@embedfont@fontstart{##1}}%
^^B    \define@key{ucembedfont}{num}{\def\uc@embedfont@fontstart{##1}}%
^^B    \define@key{ucembedfont}{option}{\def\uc@embedfont@option{##1}}%
^^B  \fi
^^B  \let\uc@embedfont@enc\undefined % Ignored
^^B  \let\uc@embedfont@start\undefined
^^B  \def\uc@embedfont@fontstart{0}%
^^B  \let\uc@embedfont@num\undefined
^^B  \def\uc@embedfont@option{document}%
^^B  \setkeys{ucembedfont}{#1}%
^^B  \ifx\uc@embedfont@start\undefined
^^B    \uc@errormsg{\string\UnicodeEmbedFont\space
^^B                 needs argument start=...}{}\fi
^^B  \edef\uc@embedfont@fontstart{\number\uc@embedfont@fontstart}%
^^B  \edef\uc@embedfont@start{\number\uc@embedfont@start}%
^^B  \ifx\uc@embedfont@num\undefined
^^B    \@tempcnta-\uc@embedfont@fontstart
^^B    \advance\@tempcnta by256
^^B    \edef\uc@embedfont@num{\number\@tempcnta}%
^^B  \fi
^^B  \@tempcnta0
^^B  \@tempcntb\uc@embedfont@fontstart
^^B  \loop\ifnum\@tempcnta<\uc@embedfont@num
^^B    \advance\@tempcnta by\uc@embedfont@start
^^B    \edef\uc@temp@a{%
^^B      \noexpand\char\number\@tempcntb\space}%
^^B    \expandafter\DeclareUnicodeCharacterAsOptional
^^B      \expandafter{\expandafter\@tempcnta\expandafter}%
^^B      \expandafter{\expandafter\uc@embedfont@option\expandafter}%
^^B      \expandafter{\uc@temp@a}%
^^B    \advance\@tempcnta by-\uc@embedfont@start
^^B    \advance\@tempcntb by1
^^B    \advance\@tempcnta by1
^^B  \repeat
^^B}
\@ucsutils@section\univerb
^^B\def\uc@vbsetchar#1#2{%
^^B  \catcode#1\active
^^B  \begingroup\uccode`\~#1\uppercase{\endgroup\edef~}{#2}}
^^B\DeclareRobustCommand\univerb[1][]{\ifx\@nil#1\@nil\else\PackageError{ucs}{%
^^B    \string\univerb\space has optional argument}{%
^^B    \string\univerb[...] is not supported}\fi%
^^B  \bgroup
^^B  \@tempcnta\@ne
^^B  \loop\ifnum\@tempcnta<128\relax
^^B    \uc@vbsetchar\@tempcnta{\noexpand\unichar{\number\@tempcnta}}%
^^B    \advance\@tempcnta by\@ne
^^B  \repeat
^^B  \uc@vbsetchar{32}{\noexpand\unicodecombine\noexpand\unichar{32}}%
^^B  \uc@vbsetchar{13}{\noexpand\unicodecombine\noexpand\leavevmode\noexpand\\%
^^B    \noexpand\leavevmode}%
^^B  \def\verb@egroup{%
^^B    \SetUnicodeOption{nocombine}%
^^B    \global\let\verb@balance@group\@empty\egroup}%
^^B  \SetUnicodeOption{combine}%
^^B  \@sverb}
\@ucsutils@section\unistring
^^B\def\uc@spacechar{\futurelet\uc@spacechar\empty}\expandafter\uc@spacechar\uc@spc
^^B\def\@unistring#1{%
^^B  \ifx\uc@temp@a\uc@spacechar
^^B    \@temptokena\expandafter{\the\@temptokena\unicodecombine\unichar{32}}%
^^B  \fi
^^B  \ifx\tw@#1\else
^^B    \ifx\@ne#1\else
^^B      \ifnum`#1<128
^^B        \@temptokena\expandafter{\the\@temptokena\unichar{`#1}}%
^^B      \else
^^B        \@temptokena\expandafter{\the\@temptokena#1}%
^^B      \fi
^^B    \fi%
^^B    \expandafter\futurelet\expandafter\uc@temp@a\expandafter\@unistring
^^B  \fi
^^B}
^^B\DeclareRobustCommand\unistring[1]{%
^^B  \let\uc@temp@a\undefined
^^B  \@temptokena{}%
^^B  \@unistring\@ne#1\tw@
^^B  {\SetUnicodeOption{combine}%
^^B  \the\@temptokena
^^B  \SetUnicodeOption{nocombine}}}
{\def\\#1{%
    \ifx#11%
    \uc@errormsg{Can't load \string#1}{You have given the option
      \expandafter\@gobble\string#1 to ucsutils,\MessageBreak but
        there is no command called \string#1 in ucsutils.sty.}%
      \global\let#1\undefined
    \fi}
  \@ucsutils}%
\let\@ucsutils\undefined
\let\@ucsutils@section\undefined
\catcode2=15