%%
%% 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>
%% Copyright 2022 David Carlisle https://github.com/LaTeX-Package-Repositories/ucs
%% 
%% 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\protected\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
