%% The LaTeX package sanitize-umlaut - version 1.2.1 (2022/06/29)
%% sanitize-umlaut.sty: Sanitize umlauts for makeindex
%%
%% -------------------------------------------------------------------------------------------
%% Copyright (c) 2016-2022 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
%%   https://www.latex-project.org/lppl.txt
%% and version 1.3c 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}[2022/06/29 version 1.2.1 sanitize umlauts]

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


% BEGIN: patch for 'utf8.def'
\long\def\sanitize@umlaut@UTFviii@two@octets{%
  \ifincsname
    \expandafter \UTF@two@octets@string
  \fi
  \UTFviii@two@octets@combine
}

\begingroup
\catcode`\~13
\catcode`\"12
\gdef\sanitize@umlaut@local@UTFviii@redefinition{%
  \def\UTFviii@tmp{\edef~{\noexpand\sanitize@umlaut@UTFviii@two@octets\noexpand~}}%
  \uccode`\~"C3%
  \uppercase\expandafter{\UTFviii@tmp}%
}
\endgroup
% END: patch for 'utf8.def'


\begingroup
\catcode`\"=12

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

\gdef\sanitize@umlaut@utfviii@old{%
  \sanitize@unicode@char{^^c3^^a4}{"a}%
  \sanitize@unicode@char{^^c3^^b6}{"o}%
  \sanitize@unicode@char{^^c3^^bc}{"u}%
  \sanitize@unicode@char{^^c3^^84}{"A}%
  \sanitize@unicode@char{^^c3^^96}{"O}%
  \sanitize@unicode@char{^^c3^^9c}{"U}%
  \sanitize@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{utf8-2018}\ifx\inputencodingname\@tempa
    \let\sanitize@umlaut\sanitize@umlaut@utfviii@old
    \PackageInfo{sanitize-umlaut}{encoding utf8-2018 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\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}}}
