summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/sanitize-umlaut/sanitize-umlaut.sty
blob: d48a86874a0aca67fdf34fa471ff72b5cc12e683 (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
%% The LaTeX package sanitize-umlaut - version 1.00 (2016/05/28)
%% sanitize-umlaut.sty: Sanitize umlauts for makeindex
%%
%% --------------------------------------------------------------------------------------
%% Copyright (c) 2016 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de>
%% --------------------------------------------------------------------------------------
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% 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 `author-maintained'.
%%
%% This work consists of all files listed in README
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{sanitize-umlaut}[2016/05/28 version 1.00 sanitize umlauts]

\def\define@unicode@char#1#2{%
  \@namedef{u8:\detokenize{#1}}{#2}%
}

\begingroup
\catcode`\"=12

\gdef\sanitize@umlaut@utfviii{%
  \define@unicode@char{^^c3^^a4}{"a}%
  \define@unicode@char{^^c3^^b6}{"o}%
  \define@unicode@char{^^c3^^bc}{"u}%
  \define@unicode@char{^^c3^^84}{"A}%
  \define@unicode@char{^^c3^^96}{"O}%
  \define@unicode@char{^^c3^^9c}{"U}%
  \define@unicode@char{^^c3^^9f}{"s}%
}

\gdef\sanitize@umlaut@latini{%
  \DeclareInputText{228}{"a}%
  \DeclareInputText{246}{"o}%
  \DeclareInputText{252}{"u}%
  \DeclareInputText{196}{"A}%
  \DeclareInputText{214}{"O}%
  \DeclareInputText{220}{"U}%
  \DeclareInputText{223}{"s}%
}

\gdef\sanitize@umlaut@applemac{%
  \DeclareInputText{138}{"a}%
  \DeclareInputText{154}{"o}%
  \DeclareInputText{159}{"u}%
  \DeclareInputText{128}{"A}%
  \DeclareInputText{133}{"O}%
  \DeclareInputText{134}{"U}%
  \DeclareInputText{167}{"s}%
}

\endgroup


\ifdefined\inputencodingname
  \def\@tempa{utf8}\ifx\inputencodingname\@tempa
    \let\sanitize@umlaut\sanitize@umlaut@utfviii
    \PackageInfo{sanitize-umlaut}{encoding utf8 selected}
  \else\def\@tempa{latin1}\ifx\inputencodingname\@tempa
    \let\sanitize@umlaut\sanitize@umlaut@latini
    \PackageInfo{sanitize-umlaut}{encoding latin1 selected}
  \else\def\@tempa{ansinew}\ifx\inputencodingname\@tempa
    \let\sanitize@umlaut\sanitize@umlaut@latini
    \PackageInfo{sanitize-umlaut}{encoding latin1 selected}
  \else\def\@tempa{cp1252}\ifx\inputencodingname\@tempa
    \let\sanitize@umlaut\sanitize@umlaut@latini
    \PackageInfo{sanitize-umlaut}{encoding latin1 selected}
  \else\def\@tempa{applemac}\ifx\inputencodingname\@tempa
    \let\sanitize@umlaut\sanitize@umlaut@applemac
    \PackageInfo{sanitize-umlaut}{encoding applemac selected}
  \else
    \def\sanitize@umlaut{}%
    \PackageWarning{sanitize-umlaut}{encoding \inputencodingname\space is not supported}
  \fi\fi\fi\fi\fi
\else
  \let\sanitize@umlaut\sanitize@umlaut@utfviii
  \PackageWarning{sanitize-umlaut}{encoding unknown. utf8 is selected as fallback (possibly nonsense)}
\fi

\AtBeginDocument{\edef\@sanitize{\unexpanded\expandafter{\@sanitize}\unexpanded\expandafter{\sanitize@umlaut}}}