% \iffalse meta-comment
%
% File: rotchiffre.dtx
% Version: 2016/05/16 v1.1
% Info: Perform simple rotation ciphers
%
% Copyright (C) 2010 by
%    Heiko Oberdiek <heiko.oberdiek at googlemail.com>
%    2016
%    https://github.com/ho-tex/oberdiek/issues
%
% 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.
%
% The Base Interpreter refers to any `TeX-Format',
% because some files are installed in TDS:tex/generic//.
%
% This work consists of the main source file rotchiffre.dtx
% and the derived files
%    rotchiffre.sty, rotchiffre.pdf, rotchiffre.ins, rotchiffre.drv,
%    rotchiffre-test1.tex, rotchiffre-test2.tex.
%
% Distribution:
%    CTAN:macros/latex/contrib/oberdiek/rotchiffre.dtx
%    CTAN:macros/latex/contrib/oberdiek/rotchiffre.pdf
%
% Unpacking:
%    (a) If rotchiffre.ins is present:
%           tex rotchiffre.ins
%    (b) Without rotchiffre.ins:
%           tex rotchiffre.dtx
%    (c) If you insist on using LaTeX
%           latex \let\install=y\input{rotchiffre.dtx}
%        (quote the arguments according to the demands of your shell)
%
% Documentation:
%    (a) If rotchiffre.drv is present:
%           latex rotchiffre.drv
%    (b) Without rotchiffre.drv:
%           latex rotchiffre.dtx; ...
%    The class ltxdoc loads the configuration file ltxdoc.cfg
%    if available. Here you can specify further options, e.g.
%    use A4 as paper format:
%       \PassOptionsToClass{a4paper}{article}
%
%    Programm calls to get the documentation (example):
%       pdflatex rotchiffre.dtx
%       makeindex -s gind.ist rotchiffre.idx
%       pdflatex rotchiffre.dtx
%       makeindex -s gind.ist rotchiffre.idx
%       pdflatex rotchiffre.dtx
%
% Installation:
%    TDS:tex/generic/oberdiek/rotchiffre.sty
%    TDS:doc/latex/oberdiek/rotchiffre.pdf
%    TDS:doc/latex/oberdiek/test/rotchiffre-test1.tex
%    TDS:doc/latex/oberdiek/test/rotchiffre-test2.tex
%    TDS:source/latex/oberdiek/rotchiffre.dtx
%
%<*ignore>
\begingroup
  \catcode123=1 %
  \catcode125=2 %
  \def\x{LaTeX2e}%
\expandafter\endgroup
\ifcase 0\ifx\install y1\fi\expandafter
         \ifx\csname processbatchFile\endcsname\relax\else1\fi
         \ifx\fmtname\x\else 1\fi\relax
\else\csname fi\endcsname
%</ignore>
%<*install>
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
\Msg{* Package: rotchiffre 2016/05/16 v1.1 Perform simple rotation ciphers (HO)}
\Msg{************************************************************************}

\keepsilent
\askforoverwritefalse

\let\MetaPrefix\relax
\preamble

This is a generated file.

Project: rotchiffre
Version: 2016/05/16 v1.1

Copyright (C) 2010 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.

The Base Interpreter refers to any `TeX-Format',
because some files are installed in TDS:tex/generic//.

This work consists of the main source file rotchiffre.dtx
and the derived files
   rotchiffre.sty, rotchiffre.pdf, rotchiffre.ins, rotchiffre.drv,
   rotchiffre-test1.tex, rotchiffre-test2.tex.

\endpreamble
\let\MetaPrefix\DoubleperCent

\generate{%
  \file{rotchiffre.ins}{\from{rotchiffre.dtx}{install}}%
  \file{rotchiffre.drv}{\from{rotchiffre.dtx}{driver}}%
  \usedir{tex/generic/oberdiek}%
  \file{rotchiffre.sty}{\from{rotchiffre.dtx}{package}}%
  \usedir{doc/latex/oberdiek/test}%
  \file{rotchiffre-test1.tex}{\from{rotchiffre.dtx}{test1}}%
  \file{rotchiffre-test2.tex}{\from{rotchiffre.dtx}{test2}}%
  \nopreamble
  \nopostamble
  \usedir{source/latex/oberdiek/catalogue}%
  \file{rotchiffre.xml}{\from{rotchiffre.dtx}{catalogue}}%
}

\catcode32=13\relax% active space
\let =\space%
\Msg{************************************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the following}
\Msg{* file into a directory searched by TeX:}
\Msg{*}
\Msg{*     rotchiffre.sty}
\Msg{*}
\Msg{* To produce the documentation run the file `rotchiffre.drv'}
\Msg{* through LaTeX.}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
\Msg{************************************************************************}

\endbatchfile
%</install>
%<*ignore>
\fi
%</ignore>
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{rotchiffre.drv}%
  [2016/05/16 v1.1 Perform simple rotation ciphers (HO)]%
\documentclass{ltxdoc}
\usepackage{holtxdoc}[2011/11/22]
\usepackage{rotchiffre}[2016/05/16]
\usepackage{wasysym}
\begin{document}
  \DocInput{rotchiffre.dtx}%
\end{document}
%</driver>
% \fi
%
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \GetFileInfo{rotchiffre.drv}
%
% \title{The \xpackage{rotchiffre} package}
% \date{2016/05/16 v1.1}
% \author{Heiko Oberdiek\thanks
% {Please report any issues at https://github.com/ho-tex/oberdiek/issues}\\
% \xemail{heiko.oberdiek at googlemail.com}}
%
% \maketitle
%
% \begin{abstract}
% This package implements chiffres ROT13 with its variants
% ROT5, ROT18, and ROT47.
% \end{abstract}
%
% \tableofcontents
%
% \section{Documentation}
%
% \subsection{Motivation}
%
% In the newsgroup \xnewsgroup{comp.text.tex} there was a discussion
% \cite{fontspecthread}
% about package \xpackage{fontspec}. Stephan Hennig provided
% an example to implement ROT13 as OpenType feature \cite{rot13modern}.
% And Robin Fairbairns requested a CTAN upload \cite{rot13robin} \smiley.
%
% But I think it would be not fair to the users of old \TeX\ engines
% without OpenType support that they will not be able to
% decrypt texts generated by the new package \smiley.
% Therefore I have written this package that implements ROT13
% even for \iniTeX. Also other variants ROT5, ROT18, ROT47 are
% provided.
%
% \subsection{Usage}
%
% \begin{declcs}{EdefRot} \M{type} \M{cmd} \M{text}
% \end{declcs}
% The \meta{text} is expanded and sanitized. All tokens
% are letters with catcode 12 (other) with the exeption of
% the space token that has character code 32 (0x20) and
% catcode 10 (space). This follows \hologo{TeX}'s convention of
% \cs{string} and \cs{meaning}.
%
% The chiffre type is specified by \meta{type} it takes
% a number. For example, ROT13 is specified by |13|.
% The selected chiffre is applied to \meta{text} and
% the result is stored in macro \meta{cmd}.
%
% The following table lists the supported rotation chiffres.
% \begin{center}
% \renewcommand*{\arraystretch}{1.2}
% \begin{tabular}{lll}
%   chiffre & from & to\\
% \hline
%   \textbf{ROT13} & |A|-|Z| & |N|-|Z|\,|A|-|M|\\
%                  & |a|-|z| & |n|-|z|\,|a|-|m|\\
% \hline
%   \textbf{ROT5}  & |0|-|9| & |5|-|9|\,|0|-|4|\\
% \hline
%   \textbf{ROT18} & |A|-|Z|\,|0|-|9| & |S|-|Z|\,|0|-|9|\,|A|-|R|\\
%                  & |a|-|z| & |n|-|z|\,|a|-|m|\\
% \hline
%   \textbf{ROT47} & |!|-|~| & |P|-|~|\,|!|-|O|\\
% \end{tabular}
% \end{center}
% In case of ROT47 the range is the ASCII range from character codes
% 33 (0x21) `|!|' upto 126 (0xFE) `|~|'.
%
% The specifications of the algorithms are taken from the description
% in Wikipedia \cite{wiki:rot13:de,wiki:rot13:en}, ROT18 is further
% specified by ``computerfreak'' \cite{cf:rot18}.
%
% \subsubsection{Examples}
%
% The famous English pangram \cite{lazydog} is converted by
% \begin{quote}
%   |\EdefRot{13}\result{The quick brown fox jumps over the lazy dog}|
% \end{quote}
% The result is stored in macro \cs{result} with
% the following contents:
% \begin{quote}
%   \EdefRot{13}\result{The quick brown fox jumps over the lazy dog}
%   \texttt{\result}
% \end{quote}
%
% Command names are converted to strings before. Therefore the
% text should not contain \hologo{TeX} markup, example:
% \begin{quote}
%   \def\Input{Hello\par World}
%   \EdefRot{13}\result\Input
%   |\EdefRot{13}\result{\texttt{Hello}\par\textit{World}}|\\
%   \cs{result} $\rightarrow$ \texttt{\result}
% \end{quote}
% But macros can be used that contain text. They are expanded.
% \begin{quote}
%   \def\Name{Heiko}
%   \def\Email{heiko.oberdiek at googlemail.com}
%   \EdefRot{13}\result{Hello \Name\space<\Email>}
%   |\newcommand{\Name}{Heiko}|\\
%   |\newcommand{\Email}{heiko.oberdiek at googlemail.com}|\\
%   |\EdefRot{13}\result{Hello \Name\space<\Email>}|\\
%   \cs{result} $\rightarrow$ \texttt{\result}
% \end{quote}
%
%
% \StopEventually{
% }
%
% \section{Implementation}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
% \subsection{Reload check and package identification}
%    Reload check, especially if the package is not used with \LaTeX.
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5 % ^^M
  \endlinechar=13 %
  \catcode35=6 % #
  \catcode39=12 % '
  \catcode44=12 % ,
  \catcode45=12 % -
  \catcode46=12 % .
  \catcode58=12 % :
  \catcode64=11 % @
  \catcode123=1 % {
  \catcode125=2 % }
  \expandafter\let\expandafter\x\csname ver@rotchiffre.sty\endcsname
  \ifx\x\relax % plain-TeX, first loading
  \else
    \def\empty{}%
    \ifx\x\empty % LaTeX, first loading,
      % variable is initialized, but \ProvidesPackage not yet seen
    \else
      \expandafter\ifx\csname PackageInfo\endcsname\relax
        \def\x#1#2{%
          \immediate\write-1{Package #1 Info: #2.}%
        }%
      \else
        \def\x#1#2{\PackageInfo{#1}{#2, stopped}}%
      \fi
      \x{rotchiffre}{The package is already loaded}%
      \aftergroup\endinput
    \fi
  \fi
\endgroup%
%    \end{macrocode}
%    Package identification:
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5 % ^^M
  \endlinechar=13 %
  \catcode35=6 % #
  \catcode39=12 % '
  \catcode40=12 % (
  \catcode41=12 % )
  \catcode44=12 % ,
  \catcode45=12 % -
  \catcode46=12 % .
  \catcode47=12 % /
  \catcode58=12 % :
  \catcode64=11 % @
  \catcode91=12 % [
  \catcode93=12 % ]
  \catcode123=1 % {
  \catcode125=2 % }
  \expandafter\ifx\csname ProvidesPackage\endcsname\relax
    \def\x#1#2#3[#4]{\endgroup
      \immediate\write-1{Package: #3 #4}%
      \xdef#1{#4}%
    }%
  \else
    \def\x#1#2[#3]{\endgroup
      #2[{#3}]%
      \ifx#1\@undefined
        \xdef#1{#3}%
      \fi
      \ifx#1\relax
        \xdef#1{#3}%
      \fi
    }%
  \fi
\expandafter\x\csname ver@rotchiffre.sty\endcsname
\ProvidesPackage{rotchiffre}%
  [2016/05/16 v1.1 Perform simple rotation ciphers (HO)]%
%    \end{macrocode}
%
% \subsection{Catcodes}
%
%    \begin{macrocode}
\begingroup\catcode61\catcode48\catcode32=10\relax%
  \catcode13=5 % ^^M
  \endlinechar=13 %
  \catcode123=1 % {
  \catcode125=2 % }
  \catcode64=11 % @
  \def\x{\endgroup
    \expandafter\edef\csname RotCh@AtEnd\endcsname{%
      \endlinechar=\the\endlinechar\relax
      \catcode13=\the\catcode13\relax
      \catcode32=\the\catcode32\relax
      \catcode35=\the\catcode35\relax
      \catcode61=\the\catcode61\relax
      \catcode64=\the\catcode64\relax
      \catcode123=\the\catcode123\relax
      \catcode125=\the\catcode125\relax
    }%
  }%
\x\catcode61\catcode48\catcode32=10\relax%
\catcode13=5 % ^^M
\endlinechar=13 %
\catcode35=6 % #
\catcode64=11 % @
\catcode123=1 % {
\catcode125=2 % }
\def\TMP@EnsureCode#1#2{%
  \edef\RotCh@AtEnd{%
    \RotCh@AtEnd
    \catcode#1=\the\catcode#1\relax
  }%
  \catcode#1=#2\relax
}
\TMP@EnsureCode{42}{12}% *
\TMP@EnsureCode{43}{12}% +
\TMP@EnsureCode{45}{12}% -
\TMP@EnsureCode{46}{12}% .
\TMP@EnsureCode{47}{12}% /
\TMP@EnsureCode{60}{12}% <
\TMP@EnsureCode{62}{12}% >
\TMP@EnsureCode{91}{12}% [
\TMP@EnsureCode{93}{12}% ]
\TMP@EnsureCode{96}{12}% `
\edef\RotCh@AtEnd{\RotCh@AtEnd\noexpand\endinput}
%    \end{macrocode}
%
% \subsection{Loading resources}
%
%    \begin{macrocode}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname RequirePackage\endcsname\relax
  \input infwarerr.sty\relax
  \input ltxcmds.sty\relax
  \input pdfescape.sty\relax
\else
  \RequirePackage{infwarerr}[2010/04/08]%
  \RequirePackage{ltxcmds}[2010/03/01]%
  \RequirePackage{pdfescape}[2010/03/01]%
\fi
%    \end{macrocode}
%
% \subsection{\cs{EdefRot} as robust macro}
%
%    The main macro \cs{EdefRot} is made robust if
%    \hologo{eTeX} or \hologo{LaTeX} are present.
%    \begin{macro}{\EdefRot}
%    \begin{macrocode}
\ltx@IfUndefined{protected}{%
  \ltx@IfUndefined{DeclareRobustCommand}{%
    \def\RotCh@temp{\def\EdefRot##1}%
  }{%
    \def\RotCh@temp{\DeclareRobustCommand*\EdefRot[1]}%
  }%
}{%
  \def\RotCh@temp{\protected\def\EdefRot##1}%
}
\RotCh@temp{%
  \RotCh@GetNumber{#1}%
  \ltx@IfUndefined{RotCh@rot@\romannumeral\RotCh@number}{%
    \@PackageError{rotchiffre}{%
      Unknown chiffre ROT\RotCh@number
    }\@ehc
    \EdefSanitize
  }{%
    \RotCh@rot
  }%
}
%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\RotCh@GetNumber}
%    If \hologo{eTeX} is active, then
%    the chiffre number can be an expression supported
%    by \cs{numexpr}.
%    \begin{macrocode}
\ltx@IfUndefined{numexpr}{%
  \def\RotCh@GetNumber#1{%
    \edef\RotCh@number{\number#1}%
  }%
}{%
  \def\RotCh@GetNumber#1{%
    \edef\RotCh@number{\the\numexpr#1\relax}%
  }%
}
%    \end{macrocode}
%    \end{macro}
%
% \subsection{Set \cs{lccode} on a range of characters}
%
%    \begin{macro}{\RotCh@count}
%    \begin{macrocode}
\countdef\RotCh@count=255 %
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\RotCh@count@end}
%    \begin{macrocode}
\countdef\RotCh@count@end=2 %
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{RotCh@RangeIgnore}
%    \begin{macrocode}
\def\RotCh@RangeIgnore{%
  \RotCh@loop{%
    \lccode\RotCh@count=\ltx@zero
  }%
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\RotCh@RangeSet}
%    \begin{macrocode}
\ltx@IfUndefined{numexpr}{%
  \countdef\RotCh@count@temp=4 %
  \def\RotCh@RangeSet#1{%
    \RotCh@loop{%
       \RotCh@count@temp=\RotCh@count
       \advance\RotCh@count@temp #1 %
       \lccode\RotCh@count=\RotCh@count@temp
    }%
  }%
}{%
  \def\RotCh@RangeSet#1{%
    \RotCh@loop{%
      \lccode\RotCh@count=\numexpr\RotCh@count#1\relax
    }%
  }%
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\RotCh@loop}
%    \begin{macrocode}
\def\RotCh@loop#1#2#3{%
  \RotCh@count=#2 %
  \RotCh@count@end=#3 %
  \def\RotCh@action{#1}%
  \RotCh@@loop
}%
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{RotCh@@loop}
%    \begin{macrocode}
\def\RotCh@@loop{%
  \RotCh@action
  \ifnum\RotCh@count<\RotCh@count@end
    \advance\RotCh@count\ltx@one
    \expandafter\RotCh@@loop
  \fi
}
%    \end{macrocode}
%    \end{macro}
%
% \subsection{Chiffres}
%
% \subsubsection{ROT13}
%
%    \begin{macro}{\RotCh@rot@xiii}
%    \begin{macrocode}
\def\RotCh@rot@xiii{%
  \RotCh@RangeIgnore{0}{64}%
  \RotCh@RangeSet{+13}{65}{77}%
  \RotCh@RangeSet{-13}{78}{90}%
  \RotCh@RangeIgnore{91}{96}%
  \RotCh@RangeSet{+13}{97}{109}%
  \RotCh@RangeSet{-13}{110}{122}%
  \RotCh@RangeIgnore{123}{255}%
}
%    \end{macrocode}
%    \end{macro}
%
% \subsubsection{ROT5}
%
%    \begin{macro}{\RotCh@rot@v}
%    \begin{macrocode}
\def\RotCh@rot@v{%
  \RotCh@RangeIgnore{0}{47}%
  \RotCh@RangeSet{+5}{48}{52}%
  \RotCh@RangeSet{-5}{53}{57}%
  \RotCh@RangeIgnore{58}{255}%
}
%    \end{macrocode}
%    \end{macro}
%
% \subsubsection{ROT18}
%
%    \begin{macro}{\RotCh@rot@xviii}
%    \begin{macrocode}
\def\RotCh@rot@xviii{%
  \RotCh@RangeIgnore{0}{47}%
  \RotCh@RangeSet{+25}{48}{57}%
  \RotCh@RangeIgnore{58}{64}%
  \RotCh@RangeSet{+18}{65}{72}%
  \RotCh@RangeSet{-25}{73}{82}%
  \RotCh@RangeSet{-18}{83}{90}%
  \RotCh@RangeIgnore{91}{96}%
  \RotCh@RangeSet{+13}{97}{109}%
  \RotCh@RangeSet{-13}{110}{122}%
  \RotCh@RangeIgnore{123}{255}%
}
%    \end{macrocode}
%    \end{macro}
%
% \subsubsection{ROT47}
%
%    \begin{macro}{\RotCh@rot@xlvii}
%    \begin{macrocode}
\def\RotCh@rot@xlvii{%
  \RotCh@RangeIgnore{0}{32}%
  \RotCh@RangeSet{+47}{33}{79}%
  \RotCh@RangeSet{-47}{80}{126}%
  \RotCh@RangeIgnore{127}{255}%
}
%    \end{macrocode}
%    \end{macro}
%
% \subsection{\cs{RotCh@rot} with big char support}
%
% Some modern \hologo{TeX} engines support characters with more
% than eight bits (codes greater as 255). \hologo{LuaTeX} and
% \hologo{XeTeX} are detected by the caret notation that is
% extended by these engines.
%    \begin{macrocode}
\begingroup
  \catcode0=9 %
  \catcode`\^=7 %
  \catcode`\^^^=12 %
  \def\x{^^^^0000}%
\expandafter\endgroup
\ifx\x\ltx@empty
%    \end{macrocode}
%
%    \begin{macro}{\RotCh@toks}
%    \begin{macrocode}
  \toksdef\RotCh@toks=0 %
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\RotCh@rot}
%    \begin{macrocode}
  \long\def\RotCh@rot#1#2{%
    \EdefSanitize#1{#2}%
    \begingroup
      \csname RotCh@rot@\romannumeral\RotCh@number\endcsname
      \RotCh@toks={}%
      \expandafter\RotCh@SplitSpace#1 \@nil
    \expandafter\endgroup
    \expandafter\def\expandafter#1\expandafter{%
      \the\RotCh@toks
    }%
  }%
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\RotCh@SplitSpace}
%    \begin{macrocode}
  \def\RotCh@temp#1{%
    \def\RotCh@SplitSpace##1 ##2\@nil{%
      \RotCh@Add##1\relax
      \ifx\relax##2\relax
        \expandafter\ltx@gobble
      \else
        \RotCh@toks\expandafter{\the\RotCh@toks#1}%
        \expandafter\ltx@firstofone
      \fi
      {%
        \RotCh@SplitSpace##2\@nil
      }%
    }%
  }%
  \RotCh@temp{ }%
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\RotCh@Add}
%    \begin{macrocode}
  \def\RotCh@Add#1{%
    \ifx#1\relax
    \else
      \ifnum`#1>126 %
        \RotCh@toks\expandafter{\the\RotCh@toks#1}%
      \else
        \lowercase{%
          \RotCh@toks\expandafter{\the\RotCh@toks#1}%
        }%
      \fi
      \expandafter\RotCh@Add
    \fi
  }%
%    \end{macrocode}
%    \end{macro}
%    \begin{macrocode}
\else
%    \end{macrocode}
%
% \subsection{\cs{RotCh@rot} without big char support}
%
%    \begin{macro}{\RotCh@rot}
%    \begin{macrocode}
  \long\def\RotCh@rot#1#2{%
    \EdefSanitize#1{#2}%
    \begingroup
      \csname RotCh@rot@\romannumeral\RotCh@number\endcsname
    \lowercase\expandafter{\expandafter\endgroup
      \expandafter\def\expandafter#1\expandafter{#1}%
    }%
  }%
%    \end{macrocode}
%    \end{macro}
%    \begin{macrocode}
\fi
%    \end{macrocode}
%
%    \begin{macrocode}
\RotCh@AtEnd%
%</package>
%    \end{macrocode}
%
% \section{Test}
%
% \subsection{Catcode checks for loading}
%
%    \begin{macrocode}
%<*test1>
%    \end{macrocode}
%    \begin{macrocode}
\catcode`\{=1 %
\catcode`\}=2 %
\catcode`\#=6 %
\catcode`\@=11 %
\expandafter\ifx\csname count@\endcsname\relax
  \countdef\count@=255 %
\fi
\expandafter\ifx\csname @gobble\endcsname\relax
  \long\def\@gobble#1{}%
\fi
\expandafter\ifx\csname @firstofone\endcsname\relax
  \long\def\@firstofone#1{#1}%
\fi
\expandafter\ifx\csname loop\endcsname\relax
  \expandafter\@firstofone
\else
  \expandafter\@gobble
\fi
{%
  \def\loop#1\repeat{%
    \def\body{#1}%
    \iterate
  }%
  \def\iterate{%
    \body
      \let\next\iterate
    \else
      \let\next\relax
    \fi
    \next
  }%
  \let\repeat=\fi
}%
\def\RestoreCatcodes{}
\count@=0 %
\loop
  \edef\RestoreCatcodes{%
    \RestoreCatcodes
    \catcode\the\count@=\the\catcode\count@\relax
  }%
\ifnum\count@<255 %
  \advance\count@ 1 %
\repeat

\def\RangeCatcodeInvalid#1#2{%
  \count@=#1\relax
  \loop
    \catcode\count@=15 %
  \ifnum\count@<#2\relax
    \advance\count@ 1 %
  \repeat
}
\def\RangeCatcodeCheck#1#2#3{%
  \count@=#1\relax
  \loop
    \ifnum#3=\catcode\count@
    \else
      \errmessage{%
        Character \the\count@\space
        with wrong catcode \the\catcode\count@\space
        instead of \number#3%
      }%
    \fi
  \ifnum\count@<#2\relax
    \advance\count@ 1 %
  \repeat
}
\def\space{ }
\expandafter\ifx\csname LoadCommand\endcsname\relax
  \def\LoadCommand{\input rotchiffre.sty\relax}%
\fi
\def\Test{%
  \RangeCatcodeInvalid{0}{47}%
  \RangeCatcodeInvalid{58}{64}%
  \RangeCatcodeInvalid{91}{96}%
  \RangeCatcodeInvalid{123}{255}%
  \catcode`\@=12 %
  \catcode`\\=0 %
  \catcode`\%=14 %
  \LoadCommand
  \RangeCatcodeCheck{0}{36}{15}%
  \RangeCatcodeCheck{37}{37}{14}%
  \RangeCatcodeCheck{38}{47}{15}%
  \RangeCatcodeCheck{48}{57}{12}%
  \RangeCatcodeCheck{58}{63}{15}%
  \RangeCatcodeCheck{64}{64}{12}%
  \RangeCatcodeCheck{65}{90}{11}%
  \RangeCatcodeCheck{91}{91}{15}%
  \RangeCatcodeCheck{92}{92}{0}%
  \RangeCatcodeCheck{93}{96}{15}%
  \RangeCatcodeCheck{97}{122}{11}%
  \RangeCatcodeCheck{123}{255}{15}%
  \RestoreCatcodes
}
\Test
\csname @@end\endcsname
\end
%    \end{macrocode}
%    \begin{macrocode}
%</test1>
%    \end{macrocode}
%
% \subsection{Macro tests}
%
% \subsubsection{Preamble}
%
%    \begin{macrocode}
%<*test2>
\catcode`\{=1 %
\catcode`\}=2 %
\catcode`\#=6 %
\catcode`\^=7 %
\font\rmfont=ec-lmtt10\relax
\rmfont
\showboxbreadth=10000 %
\showboxdepth=10000 %
\errorcontextlines=10000
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname RequirePackage\endcsname\relax
  \input rotchiffre.sty\relax
\else
  \RequirePackage{rotchiffre}[2016/05/16]%
  \RequirePackage{ifluatex}[2010/03/01]%
  \RequirePackage{ifxetex}[2010/09/12]%
\fi
\catcode`\@=11 %
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname @onelevel@sanitize\endcsname\relax
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname detokenize\endcsname\relax
    \def\strip@prefix#1->{}%
    \def\@onelevel@sanitize#1{%
      \edef#1{%
        \expandafter\strip@prefix\meaning#1%
      }%
    }%
  \else
    \def\@onelevel@sanitize#1{%
      \edef#1{%
        \detokenize\expandafter{#1}%
      }%
    }%
  \fi
\fi
\def\msg#{\immediate\write16}
\def\empty{}
\begingroup
  \def\x#1{%
    \def\space{#1}%
    \def\spacesII{#1#1}%
    \def\spacesIII{#1#1#1}%
    \def\spacesIV{#1#1#1#1}%
  }%
\expandafter\endgroup\x{ }
%    \end{macrocode}
%    \begin{macrocode}
\def\PrintStr#1#2{%
  \begingroup
    \@onelevel@sanitize#2%
    \msg{#1: [#2]}% hash-ok
  \endgroup
}
\def\CheckResult{%
  \PrintStr{Result}\StrResult
  \ifx\StrExpect\StrResult
    \msg{==> Ok}%
  \else
    \begingroup
    \edef\x{\endgroup
      \errmessage{Test failed (\chiffre)!}%
    }\x
  \fi
}
\long\def\test#1#2{%
  \msg{}%
  \begingroup
    \setbox0=\hbox{%
      \edef\StrInput{#1}%
      \@onelevel@sanitize\StrInput
      \PrintStr{ Input}\StrInput
      \edef\StrExpect{#2}%
      \@onelevel@sanitize\StrExpect
      \PrintStr{Expect}\StrExpect
      \action{#1}%
      \CheckResult
    }%
    \ifdim\wd0=0pt %
    \else
      \showbox0 %
    \fi
  \endgroup
}
\def\cmd#1{%
  \msg{* CMD: ROT#1}%
  \def\chiffre{ROT#1}%
  \def\action{\EdefRot{#1}\StrResult}%
}
%    \end{macrocode}
%    \begin{macrocode}
\def\TestIgnore#1{%
  \test{#1}{#1}%
}
\begingroup
  \lccode`\P=`\%%
  \lccode`\B=`\\%
  \lccode`\H=`\#%
\lowercase{\endgroup
  \def\PercentChar{P}%
  \def\BackslashChar{B}%
  \def\HashChar{H}%
}
\def\TestI{%
  \TestIgnore{%
    \space!"\HashChar$\PercentChar&'()*+,-./%
    :;<=>?@%
    [\BackslashChar]^_`%
    \string{|\string}\string~%
  }%
}
\begingroup
  \catcode0=12 %
  \lccode`A=1 %
  \lccode`B=2 %
  \lccode`C=3 %
  \lccode`D=4 %
  \lccode`E=5 %
  \lccode`F=6 %
  \lccode`G=7 %
  \lccode`H=8 %
  \lccode`I=9 %
  \lccode`J=10 %
  \lccode`K=11 %
  \lccode`L=12 %
  \lccode`M=13 %
  \lccode`N=14 %
  \lccode`O=15 %
  \lccode`P=16 %
  \lccode`Q=17 %
  \lccode`R=18 %
  \lccode`S=19 %
  \lccode`T=20 %
  \lccode`U=21 %
  \lccode`V=22 %
  \lccode`W=23 %
  \lccode`X=24 %
  \lccode`Y=25 %
  \lccode`Z=26 %
  \lccode`a=27 %
  \lccode`b=28 %
  \lccode`c=29 %
  \lccode`d=30 %
  \lccode`e=31 %
  \lccode`f=127 %
  \lccode`g=128 %
  \lccode`h=129 %
  \lccode`y=254 %
  \lccode`z=255 %
\lowercase{\endgroup
  \def\TestC{%
    \TestIgnore{%
      ^^@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefhyz%
    }%
  }%
  \def\TestZ{%
    \TestIgnore{^^@}%
  }%
}
%    \end{macrocode}
%
% \subsubsection{ROT13}
%
%    \begin{macrocode}
\cmd{13}
\test{%
  0123456789%
  ABCDEFGHIJKLMNOPQRSTUVWXYZ%
  abcdefghijklmnopqrstuvwxyz%
}{%
  0123456789%
  NOPQRSTUVWXYZABCDEFGHIJKLM%
  nopqrstuvwxyzabcdefghijklm%
}
\TestI
\TestC
\test{}{}
\test{A}{N}
\test{N}{A}
\test{ }{ }
\test{0a}{0n}
\test{\spacesIV}{\spacesIV}
\test{{}}{{}}
\test{\par}{\noexpand\cne}
%    \end{macrocode}
%
% \subsubsection{ROT5}
%
%    \begin{macrocode}
\cmd{5}
\test{%
  0123456789%
  ABCDEFGHIJKLMNOPQRSTUVWXYZ%
  abcdefghijklmnopqrstuvwxyz%
}{%
  5678901234%
  ABCDEFGHIJKLMNOPQRSTUVWXYZ%
  abcdefghijklmnopqrstuvwxyz%
}
\TestI
\TestC
%    \end{macrocode}
%
% \subsubsection{ROT18}
%
%    \begin{macrocode}
\cmd{18}
\test{%
  ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789%
  abcdefghijklmnopqrstuvwxyz%
}{%
  STUVWXYZ0123456789ABCDEFGHIJKLMNOPQR%
  nopqrstuvwxyzabcdefghijklm%
}
\TestI
\TestC
%    \end{macrocode}
%
% \subsubsection{ROT47}
%
%    \begin{macrocode}
\cmd{47}
\test{%
  !"\HashChar$\PercentChar&'()*+,-./%
  0123456789%
  :;<=>?@%
  ABCDEFGHIJKLMNOPQRSTUVWXYZ%
  [\BackslashChar]^_`%
  abcdefghijklmnopqrstuvwxyz%
  \string{|\string}\string~%
}{%
  PQRSTUVWXYZ%
  [\BackslashChar]^_`%
  abcdefghijklmnopqrstuvwxyz%
  \string{|\string}\string~%
  !"\HashChar$\PercentChar&'()*+,-./%
  0123456789%
  :;<=>?@%
  ABCDEFGHIJKLMNO%
}
\TestZ
\TestC
%    \end{macrocode}
%
% \subsubsection{Big chars}
%
%    \begin{macrocode}
\chardef\temp=0 %
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname XeTeXrevision\endcsname\relax
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname RequirePackage\endcsname\relax
    \input ifluatex.sty\relax
  \else
    \RequirePackage{ifluatex}[2010/03/01]%
  \fi
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname luatexversion\endcsname\relax
  \else
    \chardef\temp=1 %
  \fi
\else
  \chardef\temp=1 %
\fi
\ifcase\temp
  \csname @@end\expandafter\endcsname\expandafter\end
\fi
%    \end{macrocode}
%    \begin{macrocode}
\msg{* Big chars}
\cmd{5}
\test{}{}
\test{ }{ }
\test{ 0 1 }{ 5 6 }
\begingroup
  \lccode`A=300 %
  \lccode`B=1000 %
  \lccode`C=10000 %
\lowercase{\endgroup
  \TestIgnore{ABC}%
  \TestIgnore{x A By zC xAy AxB}%
}%
%    \end{macrocode}
%    \begin{macrocode}
\csname @@end\endcsname\end
%</test2>
%    \end{macrocode}
%
% \section{Installation}
%
% \subsection{Download}
%
% \paragraph{Package.} This package is available on
% CTAN\footnote{\url{http://ctan.org/pkg/rotchiffre}}:
% \begin{description}
% \item[\CTAN{macros/latex/contrib/oberdiek/rotchiffre.dtx}] The source file.
% \item[\CTAN{macros/latex/contrib/oberdiek/rotchiffre.pdf}] Documentation.
% \end{description}
%
%
% \paragraph{Bundle.} All the packages of the bundle `oberdiek'
% are also available in a TDS compliant ZIP archive. There
% the packages are already unpacked and the documentation files
% are generated. The files and directories obey the TDS standard.
% \begin{description}
% \item[\CTAN{install/macros/latex/contrib/oberdiek.tds.zip}]
% \end{description}
% \emph{TDS} refers to the standard ``A Directory Structure
% for \TeX\ Files'' (\CTAN{tds/tds.pdf}). Directories
% with \xfile{texmf} in their name are usually organized this way.
%
% \subsection{Bundle installation}
%
% \paragraph{Unpacking.} Unpack the \xfile{oberdiek.tds.zip} in the
% TDS tree (also known as \xfile{texmf} tree) of your choice.
% Example (linux):
% \begin{quote}
%   |unzip oberdiek.tds.zip -d ~/texmf|
% \end{quote}
%
% \paragraph{Script installation.}
% Check the directory \xfile{TDS:scripts/oberdiek/} for
% scripts that need further installation steps.
% Package \xpackage{attachfile2} comes with the Perl script
% \xfile{pdfatfi.pl} that should be installed in such a way
% that it can be called as \texttt{pdfatfi}.
% Example (linux):
% \begin{quote}
%   |chmod +x scripts/oberdiek/pdfatfi.pl|\\
%   |cp scripts/oberdiek/pdfatfi.pl /usr/local/bin/|
% \end{quote}
%
% \subsection{Package installation}
%
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
% \docstrip\ archive. The files are extracted by running the
% \xfile{.dtx} through \plainTeX:
% \begin{quote}
%   \verb|tex rotchiffre.dtx|
% \end{quote}
%
% \paragraph{TDS.} Now the different files must be moved into
% the different directories in your installation TDS tree
% (also known as \xfile{texmf} tree):
% \begin{quote}
% \def\t{^^A
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
%   rotchiffre.sty & tex/generic/oberdiek/rotchiffre.sty\\
%   rotchiffre.pdf & doc/latex/oberdiek/rotchiffre.pdf\\
%   test/rotchiffre-test1.tex & doc/latex/oberdiek/test/rotchiffre-test1.tex\\
%   test/rotchiffre-test2.tex & doc/latex/oberdiek/test/rotchiffre-test2.tex\\
%   rotchiffre.dtx & source/latex/oberdiek/rotchiffre.dtx\\
% \end{tabular}^^A
% }^^A
% \sbox0{\t}^^A
% \ifdim\wd0>\linewidth
%   \begingroup
%     \advance\linewidth by\leftmargin
%     \advance\linewidth by\rightmargin
%   \edef\x{\endgroup
%     \def\noexpand\lw{\the\linewidth}^^A
%   }\x
%   \def\lwbox{^^A
%     \leavevmode
%     \hbox to \linewidth{^^A
%       \kern-\leftmargin\relax
%       \hss
%       \usebox0
%       \hss
%       \kern-\rightmargin\relax
%     }^^A
%   }^^A
%   \ifdim\wd0>\lw
%     \sbox0{\small\t}^^A
%     \ifdim\wd0>\linewidth
%       \ifdim\wd0>\lw
%         \sbox0{\footnotesize\t}^^A
%         \ifdim\wd0>\linewidth
%           \ifdim\wd0>\lw
%             \sbox0{\scriptsize\t}^^A
%             \ifdim\wd0>\linewidth
%               \ifdim\wd0>\lw
%                 \sbox0{\tiny\t}^^A
%                 \ifdim\wd0>\linewidth
%                   \lwbox
%                 \else
%                   \usebox0
%                 \fi
%               \else
%                 \lwbox
%               \fi
%             \else
%               \usebox0
%             \fi
%           \else
%             \lwbox
%           \fi
%         \else
%           \usebox0
%         \fi
%       \else
%         \lwbox
%       \fi
%     \else
%       \usebox0
%     \fi
%   \else
%     \lwbox
%   \fi
% \else
%   \usebox0
% \fi
% \end{quote}
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
% TDS installing feature, then some files can already be in the right
% place, see the documentation of \docstrip.
%
% \subsection{Refresh file name databases}
%
% If your \TeX~distribution
% (\teTeX, \mikTeX, \dots) relies on file name databases, you must refresh
% these. For example, \teTeX\ users run \verb|texhash| or
% \verb|mktexlsr|.
%
% \subsection{Some details for the interested}
%
% \paragraph{Attached source.}
%
% The PDF documentation on CTAN also includes the
% \xfile{.dtx} source file. It can be extracted by
% AcrobatReader 6 or higher. Another option is \textsf{pdftk},
% e.g. unpack the file into the current directory:
% \begin{quote}
%   \verb|pdftk rotchiffre.pdf unpack_files output .|
% \end{quote}
%
% \paragraph{Unpacking with \LaTeX.}
% The \xfile{.dtx} chooses its action depending on the format:
% \begin{description}
% \item[\plainTeX:] Run \docstrip\ and extract the files.
% \item[\LaTeX:] Generate the documentation.
% \end{description}
% If you insist on using \LaTeX\ for \docstrip\ (really,
% \docstrip\ does not need \LaTeX), then inform the autodetect routine
% about your intention:
% \begin{quote}
%   \verb|latex \let\install=y\input{rotchiffre.dtx}|
% \end{quote}
% Do not forget to quote the argument according to the demands
% of your shell.
%
% \paragraph{Generating the documentation.}
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
% the documentation. The process can be configured by the
% configuration file \xfile{ltxdoc.cfg}. For instance, put this
% line into this file, if you want to have A4 as paper format:
% \begin{quote}
%   \verb|\PassOptionsToClass{a4paper}{article}|
% \end{quote}
% An example follows how to generate the
% documentation with pdf\LaTeX:
% \begin{quote}
%\begin{verbatim}
%pdflatex rotchiffre.dtx
%makeindex -s gind.ist rotchiffre.idx
%pdflatex rotchiffre.dtx
%makeindex -s gind.ist rotchiffre.idx
%pdflatex rotchiffre.dtx
%\end{verbatim}
% \end{quote}
%
% \section{Catalogue}
%
% The following XML file can be used as source for the
% \href{http://mirror.ctan.org/help/Catalogue/catalogue.html}{\TeX\ Catalogue}.
% The elements \texttt{caption} and \texttt{description} are imported
% from the original XML file from the Catalogue.
% The name of the XML file in the Catalogue is \xfile{rotchiffre.xml}.
%    \begin{macrocode}
%<*catalogue>
<?xml version='1.0' encoding='us-ascii'?>
<!DOCTYPE entry SYSTEM 'catalogue.dtd'>
<entry datestamp='$Date$' modifier='$Author$' id='rotchiffre'>
  <name>rotchiffre</name>
  <caption>Perform simple rotation cyphers.</caption>
  <authorref id='auth:oberdiek'/>
  <copyright owner='Heiko Oberdiek' year='2010'/>
  <license type='lppl1.3'/>
  <version number='1.1'/>
  <description>
    The package defines a command <tt>\EdefRot</tt> that defines a
    macro (whose name is given as an argument) to the rotation of the
    given string.  Available rotations are <tt>ROT13</tt> (for
    letters), <tt>ROT5</tt> (for digits), <tt>ROT18</tt> (for digits
    and letters together) and <tt>ROT47</tt> (for all ASCII
    characters).
    <p/>
    The package is part of the
    <xref refid='oberdiek'>oberdiek</xref> bundle.
  </description>
  <documentation details='Package documentation'
      href='ctan:/macros/latex/contrib/oberdiek/rotchiffre.pdf'/>
  <ctan file='true' path='/macros/latex/contrib/oberdiek/rotchiffre.dtx'/>
  <miktex location='oberdiek'/>
  <texlive location='oberdiek'/>
  <install path='/macros/latex/contrib/oberdiek/oberdiek.tds.zip'/>
</entry>
%</catalogue>
%    \end{macrocode}
%
% \begin{thebibliography}{9}
% \raggedright
%
% \bibitem{fontspecthread}
% Stephan Hennig et.\,al.:
% \textit{fontspec: no ligatures with Times New Roman};
% newsgroup \xnewsgroup{comp.text.tex},
% \url{news:4cdbed27$0$6765$9b4e6d93@newsspool3.arcor-online.net},
% 2010-11-11.\\
% {\small
% \url{http://groups.google.com/group/comp.text.tex/browse_thread/thread/6266f98e998ce333/d7b32e9dcc610c87}}
%
% \bibitem{rot13modern}
% Stephan Hennig:
% \textit{Re: fontspec: no ligatures with Times New Roman};
% newsgroup \xnewsgroup{comp.text.tex},
% \url{news:4cdc2abe$0$6762$9b4e6d93@newsspool3.arcor-online.net},
% 2010-11-11.\\
% {\small
% \url{http://groups.google.com/group/comp.text.tex/msg/d7b32e9dcc610c87}}
%
% \bibitem{rot13robin}
% Robin Fairbairns:
% \textit{Re: fontspec: no ligatures with Times New Roman};
% newsgroup \xnewsgroup{comp.text.tex},
% \url{news:qf4obmua0v.fsf@sxp10.cl.cam.ac.uk},
% 2010-11-12.\\
% {\small
% \url{http://groups.google.com/group/comp.text.tex/msg/7c03e91407144704}}
%
% \bibitem{wiki:rot13:de}
% Wikipedia/German:
% \textit{ROT13};
% 2010-10-26.
% {\small
% \url{http://de.wikipedia.org/wiki/ROT13}}
%
% \bibitem{wiki:rot13:en}
% Wikipedia/English:
% \textit{ROT13};
% 2010-11-11.
% {\small
% \url{http://en.wikipedia.org/wiki/ROT13}}
%
% \bibitem{cf:rot18}
% Computerfreak/German: \textit{ROT-18};
% 2010-04-12.\\
% {\small
% \url{http://www.compufreak.info/2010/04/12/rot-18/}}
%
% \bibitem{lazydog}
% Wikipedia/English: \textit{The quick brown fox jumps over the lazy dog};
% 2010-11-09.\\
% {\small
% \url{http://en.wikipedia.org/wiki/The_quick_brown_fox_jumps_over_the_lazy_dog}}
%
% \end{thebibliography}
%
% \begin{History}
%   \begin{Version}{2010/11/12 v1.0}
%   \item
%     First version.
%   \end{Version}
%   \begin{Version}{2016/05/16 v1.1}
%   \item
%     Documentation updates.
%   \end{Version}
% \end{History}
%
% \PrintIndex
%
% \Finale
\endinput
