summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/inputenx/inputenx.sty
blob: 8d4454187fd57f040156644a4d3fa337eada2078 (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
%%
%% This is file `inputenx.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% inputenx.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Project: inputenx
%% Version: 2019/11/29 v1.12
%% 
%% Copyright (C)
%%   2006-2011 Heiko Oberdiek
%%   2016-2019 Oberdiek Package Support Group
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. This version of this license is in
%%    https://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%%    https://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% The Current Maintainers of this work are
%% Heiko Oberdiek and the Oberdiek Package Support Group
%% https://github.com/ho-tex/inputenx/issues
%% 
%% 
%% This work consists of the main source file inputenx.dtx
%% and the derived files
%%    inputenx.sty, inputenx.pdf, inputenx.ins, inputenx.drv, ix-alias.def,
%%    ix-math.def, ix-name.def, ix-slot.def, ix-uc.def,
%%    ix-utf8enc.dfu, x-ascii.def, x-verbatim.def, x-atarist.def,
%%    x-iso-8859-1.def, x-iso-8859-2.def, x-iso-8859-3.def,
%%    x-iso-8859-4.def, x-iso-8859-5.def, x-iso-8859-8.def,
%%    x-iso-8859-9.def, x-iso-8859-10.def, x-iso-8859-13.def,
%%    x-iso-8859-14.def, x-iso-8859-15.def, x-iso-8859-16.def,
%%    x-cp437.def, x-cp850.def, x-cp852.def, x-cp855.def,
%%    x-cp858.def, x-cp865.def, x-cp866.def, x-cp1250.def,
%%    x-cp1251.def, x-cp1252.def, x-cp1255.def, x-cp1257.def,
%%    x-dec-mcs.def, x-koi8-r.def, x-mac-centeuro.def,
%%    x-mac-cyrillic.def, x-mac-roman.def, x-nextstep.def,
%%    inputenx-licrcmds.txt, inputenx-utf8enc.txt.
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{inputenx}%
  [2019/11/29 v1.12 Enhanced input encoding handling (HO)]%
\providecommand*{\CurrentInputEncodingName}{}
\providecommand*{\CurrentInputEncodingOption}{}
\def\IEX@SetFileCatcodes{%
  \catcode`\\=0 %
  \catcode`\{=1 %
  \catcode`\}=2 %
  \catcode`\#=6 %
  \catcode`\^=7 %
  \catcode`\@=11 %
  \catcode`\~=\active
  \catcode`\%=14 %
  \catcode`\`=12 %
}
\def\IEX@SaveFileCatcodes{%
  \edef\IEX@RestoreFileCatcodes{%
    \catcode`\noexpand\\=\the\catcode`\\\relax
    \catcode`\noexpand\{=\the\catcode`\{\relax
    \catcode`\noexpand\}=\the\catcode`\}\relax
    \catcode`\noexpand\#=\the\catcode`\#\relax
    \catcode`\noexpand\^=\the\catcode`\^\relax
    \catcode`\noexpand\@=\the\catcode`\@\relax
    \catcode`\noexpand\~=\the\catcode`\~\relax
    \catcode`\noexpand\%=\the\catcode`\%\relax
    \catcode`\noexpand\`=\the\catcode`\`\relax
    \catcode`\noexpand\<=\the\catcode`\<\relax
  }%
}
\def\IEX@LookupEncoding#1{%
  \edef\CurrentInputEncodingName{#1}%
  \@onelevel@sanitize\CurrentInputEncodingName
  \let\CurrentInputEncodingOption\@empty
  \@ifundefined{IEX@enc@\CurrentInputEncodingName}{%
    \global\expandafter\let
       \csname IEX@enc@\CurrentInputEncodingName\endcsname
       \CurrentInputEncodingName
    \IEX@DoLookup
  }{}%
  \edef\CurrentInputEncodingOption{%
    \csname IEX@enc@\CurrentInputEncodingName\endcsname
  }%
  \ifx\CurrentInputEncodingOption\@empty
    \PackageWarning{inputenx}{%
      Encoding `\CurrentInputEncodingName' is not available%
      \MessageBreak
      and therefore ignored%
    }%
  \else
    \IfFileExists{\CurrentInputEncodingOption.def}{%
      \PackageInfo{inputenx}{%
        Encoding name: \CurrentInputEncodingName\MessageBreak
        Encoding file: \CurrentInputEncodingOption.def\MessageBreak
      }%
    }{%
      \PackageError{inputenx}{%
        Cannot load encoding `\CurrentInputEncodingName'.\MessageBreak
        A valid encoding alias was not found and\MessageBreak
        encoding file `\CurrentInputEncodingOption.def' does not exist%
      }\@ehc
      \global\expandafter\let
          \csname IEX@enc@\CurrentInputEncodingName\endcsname\@empty
      \let\CurrentInputEncodingName\@empty
      \let\CurrentInputEncodingOption\@empty
    }%
  \fi
}
\def\IEX@DoLookup{%
  \begingroup
    \IEX@SetFileCatcodes
    \advance\endlinechar\@M
    \IfFileExists{ix-alias.cfg}{%
      \input{ix-alias.cfg}%
    }{%
      \input{ix-alias.def}%
    }%
    \advance\endlinechar-\@M
  \endgroup
}
\def\InputenxAlias#1#2{%
  \edef\IEX@temp{#1}%
  \@onelevel@sanitize\IEX@temp
  \ifx\IEX@temp\CurrentInputEncodingName
    \edef\IEX@temp{#2}%
    \@onelevel@sanitize\IEX@temp
    \IfFileExists{\IEX@temp.def}{%
      \global\expandafter\let
          \csname IEX@enc@\CurrentInputEncodingName\endcsname\IEX@temp
      \expandafter\endinput
    }{%
      \PackageWarning{inputenx}{%
        Missing encoding file `\IEX@temp.def'\MessageBreak
        for encoding `\CurrentInputEncodingName', continuing%
        \MessageBreak
        with lookup search%
      }%
    }%
  \fi
}
\newif\ifIEX@math
\DeclareOption{math}{\IEX@mathtrue}
\let\IEX@enclist\@empty
\DeclareOption*{%
  \ifx\IEX@enclist\@empty
    \let\IEX@enclist\CurrentOption
  \else
    \edef\IEX@enclist{\IEX@enclist,\CurrentOption}%
  \fi
}
\ProcessOptions*
\let\IEX@OptionList\@empty
\@for\CurrentOption:=\IEX@enclist\do{%
  \IEX@LookupEncoding\CurrentOption
  \ifx\CurrentInputEncodingOption\@empty
  \else
    \edef\IEX@OptionList{%
      \ifx\IEX@OptionList\@empty
      \else
        \IEX@OptionList,%
      \fi
      \CurrentInputEncodingOption
    }%
  \fi
}
\RequirePackage{inputenc}
\@for\IEX@Option:=\IEX@OptionList\do{%
  \inputencoding{\IEX@Option}%
}
\def\IEX@BeforeHook{}
\def\IEX@AfterHook{}
\newcommand*{\BeforeInputEncoding}{%
  \g@addto@macro\IEX@BeforeHook
}
\newcommand*{\AfterInputEncoding}{%
  \g@addto@macro\IEX@AfterHook
}
\newcommand*{\InputEncoding}[1]{%
  \let\InputEncodingNameOld\CurrentInputEncodingName
  \let\InputEncodingOptionOld\CurrentInputEncodingOption
  \edef\InputEncodingNew{#1}%
  \IEX@BeforeHook
  \IEX@LookupEncoding\InputEncodingNew
  \ifx\CurrentInputEncodingOption\@empty
  \else
    \IEX@SaveFileCatcodes
    \IEX@SetFileCatcodes
    \inputencoding{\CurrentInputEncodingOption}%
    \IEX@RestoreFileCatcodes
  \fi
  \IEX@AfterHook
}
\ifIEX@math
  \RequirePackage{inpmath}%
  \IfFileExists{ix-math.cfg}{%
    \input{ix-math.cfg}%
  }{%
    \input{ix-math.def}%
  }%
\fi
\endinput
%%
%% End of file `inputenx.sty'.