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
|
%%
%% This is file `selinput.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% selinput.dtx (with options: `package')
%%
%% This is a generated file.
%%
%% Copyright (C) 2007 by
%% Heiko Oberdiek <heiko.oberdiek at googlemail.com>
%%
%% 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
%% http://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%% http://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".
%%
%% This Current Maintainer of this work is Heiko Oberdiek.
%%
%% This work consists of the main source file selinput.dtx
%% and the derived files
%% selinput.sty, selinput.pdf, selinput.ins, selinput.drv,
%% selinput-test1.tex, selinput-test2.tex, selinput-test3.tex,
%% selinput-test4.tex, selinput-test5.tex.
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{selinput}
[2007/09/09 v1.2 Select input encoding (HO)]%
\RequirePackage{inputenc}
\RequirePackage{kvsetkeys}[2006/10/19]
\RequirePackage{stringenc}[2007/06/16]
\RequirePackage{kvoptions}
\newcommand*{\SelectInputEncodingList}{%
\let\SIE@EncodingList\@empty
\kvsetkeys{SelInputEnc}%
}
\newcommand*{\SelectInputMappings}[1]{%
\SIE@LoadNameDefs
\let\SIE@StringUnicode\@empty
\let\SIE@StringDest\@empty
\kvsetkeys{SelInputMap}{#1}%
\ifx\\SIE@StringUnicode\SIE@StringDest\\%
\PackageError{selinput}{%
No mappings specified%
}\@ehc
\else
\EdefUnescapeHex\SIE@StringUnicode\SIE@StringUnicode
\let\SIE@Encoding\@empty
\@for\SIE@EncodingTest:=\SIE@EncodingList\do{%
\ifx\SIE@Encoding\@empty
\StringEncodingConvertTest\SIE@temp\SIE@StringUnicode
{utf16be}\SIE@EncodingTest{%
\ifx\SIE@temp\SIE@StringDest
\let\SIE@Encoding\SIE@EncodingTest
\fi
}{}%
\fi
}%
\ifx\SIE@Encoding\@empty
\StringEncodingConvertTest\SIE@temp\SIE@StringDest
{ascii}{utf16be}{%
\def\SIE@Encoding{ascii}%
\SIE@Info{selinput}{%
Matching encoding not found, but input characters%
\MessageBreak
are 7-bit (possibly editor replacements).%
\MessageBreak
Hence using ascii encoding%
}%
}{}%
\fi
\ifx\SIE@Encoding\@empty
\PackageError{selinput}{%
Cannot find a matching encoding%
}\@ehd
\else
\ifx\SIE@Encoding\SIE@EncodingUTFviii
\SIE@LoadUnicodePackage
\ifx\SIE@UseUTFviii\@empty
\else
\let\SIE@Encoding\SIE@UseUTFviii
\fi
\fi
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname InputEncoding\endcsname\relax
\inputencoding\SIE@Encoding
\else
\InputEncoding\SIE@Encoding
\fi
\SIE@Info{selinput}{Encoding `\SIE@Encoding' selected}%
\fi
\fi
}
\def\SIE@LoadNameDefs{%
\begingroup
\endlinechar=\m@ne
\catcode92=0 % backslash
\catcode123=1 % left curly brace/beginning of group
\catcode125=2 % right curly brace/end of group
\catcode37=14 % percent/comment character
\@makeother\[%
\@makeother\]%
\@makeother\.%
\@makeother\(%
\@makeother\)%
\@makeother\/%
\@makeother\-%
\let\InputenxName\SelectInputDefineMapping
\InputIfFileExists{ix-name.def}{}{%
\PackageError{selinput}{%
Missing `ix-name.def' (part of package `inputenx')%
}\@ehd
}%
\global\let\SIE@LoadNameDefs\relax
\endgroup
}
\newcommand*{\SelectInputDefineMapping}[1]{%
\expandafter\gdef\csname SIE@@#1\endcsname
}
\kv@set@family@handler{SelInputMap}{%
\@onelevel@sanitize\kv@key
\ifx\kv@value\relax
\PackageError{selinput}{%
Missing input character for `\kv@key'%
}\@ehc
\else
\@onelevel@sanitize\kv@value
\ifx\kv@value\@empty
\PackageError{selinput}{%
Input character got lost?\MessageBreak
Missing input character for `\kv@key'%
}\@ehc
\else
\@ifundefined{SIE@@\kv@key}{%
\PackageWarning{selinput}{%
Missing definition for `\kv@key'%
}%
}{%
\edef\SIE@StringDest{%
\SIE@StringDest
\kv@value
}%
\edef\SIE@StringUnicode{%
\SIE@StringUnicode
\csname SIE@@\kv@key\endcsname
}%
}%
\fi
\fi
}
\kv@set@family@handler{SelInputEnc}{%
\@onelevel@sanitize\kv@key
\ifx\kv@value\relax
\ifx\SIE@EncodingList\@empty
\let\SIE@EncodingList\kv@key
\else
\edef\SIE@EncodingList{\SIE@EncodingList,\kv@key}%
\fi
\else
\@onelevel@sanitize\kv@value
\PackageError{selinput}{%
Illegal key value pair (\kv@key=\kv@value)\MessagBreak
in encoding list%
}\@ehc
\fi
}
\def\SIE@LoadUnicodePackage{%
\@ifpackageloaded\SIE@UnicodePackage{}{%
\RequirePackage\SIE@UnicodePackage\relax
}%
\SIE@PatchUCS
\global\let\SIE@LoadUnicodePackage\relax
}
\let\SIE@show\show
\def\SIE@PatchUCS{%
\AtBeginDocument{%
\expandafter\ifx\csname ver@ucsencs.def\endcsname\relax
\else
\let\show\SIE@show
\fi
}%
}
\SIE@PatchUCS
\AtBeginDocument{%
\let\SIE@LoadUnicodePackage\relax
}
\def\SIE@EncodingUTFviii{utf8}
\@onelevel@sanitize\SIE@EncodingUTFviii
\def\SIE@EncodingUTFviiix{utf8x}
\@onelevel@sanitize\SIE@EncodingUTFviiix
\let\SIE@UnicodePackage\@empty
\let\SIE@UseUTFviii\@empty
\let\SIE@Info\PackageInfo
\SetupKeyvalOptions{%
family=SelInput,%
prefix=SelInput@%
}
\define@key{SelInput}{utf8}{%
\def\SIE@UseUTFviii{#1}%
\@onelevel@sanitize\SIE@UseUTFviii
}
\DeclareBoolOption{ucs}
\DeclareVoidOption{warning}{%
\let\SIE@Info\PackageWarning
}
\ProcessKeyvalOptions{SelInput}
\ifSelInput@ucs
\def\SIE@UnicodePackage{ucs}%
\ifx\SIE@UseUTFviii\@empty
\let\SIE@UseUTFviii\SIE@EncodingUTFviiix
\fi
\else
\ifx\SIE@UseUTFviii\@empty
\@ifpackageloaded{ucs}{%
\let\SIE@UseUTFviii\SIE@EncodingUTFviiix
}{%
\let\SIE@UseUTFviii\SIE@EncodingUTFviii
}%
\fi
\fi
\edef\SIE@EncodingList{%
utf8,%
x-iso-8859-1,%
x-iso-8859-15,%
x-cp1252,% ansinew
x-mac-roman,%
x-iso-8859-2,%
x-iso-8859-3,%
x-iso-8859-4,%
x-iso-8859-5,%
x-iso-8859-6,%
x-iso-8859-7,%
x-iso-8859-8,%
x-iso-8859-9,%
x-iso-8859-10,%
x-iso-8859-11,%
x-iso-8859-13,%
x-iso-8859-14,%
x-iso-8859-15,%
x-mac-centeuro,%
x-mac-cyrillic,%
x-koi8-r,%
x-cp1250,%
x-cp1251,%
x-cp1257,%
x-cp437,%
x-cp850,%
x-cp852,%
x-cp855,%
x-cp858,%
x-cp865,%
x-cp866,%
x-nextstep,%
x-dec-mcs%
}%
\@onelevel@sanitize\SIE@EncodingList
\endinput
%%
%% End of file `selinput.sty'.
|