%%
%% This is file `pdfescape.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pdfescape.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2007 by Heiko Oberdiek <oberdiek@uni-freiburg.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 "maintained".
%% 
%% This Current Maintainer of this work is Heiko Oberdiek.
%% 
%% This work consists of the main source file pdfescape.dtx
%% and the derived files
%%    pdfescape.sty, pdfescape.pdf, pdfescape.ins, pdfescape.drv,
%%    pdfescape-test1.tex, pdfescape-test2.tex,
%%    pdfescape-test3.tex, pdfescape-test4.tex,
%%    pdfescape-test5.tex.
%% 
\begingroup
  \catcode44 12 % ,
  \catcode45 12 % -
  \catcode46 12 % .
  \catcode58 12 % :
  \catcode64 11 % @
  \catcode123 1 % {
  \catcode125 2 % }
  \expandafter\let\expandafter\x\csname ver@pdfescape.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
      \catcode35 6 % #
      \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{pdfescape}{The package is already loaded}%
      \aftergroup\endinput
    \fi
  \fi
\endgroup
\begingroup
  \catcode35 6 % #
  \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@pdfescape.sty\endcsname
\ProvidesPackage{pdfescape}%
  [2007/11/11 v1.8 Provides hex, PDF name and string conversions (HO)]
\expandafter\edef\csname PE@AtEnd\endcsname{%
  \catcode64 \the\catcode64\relax
}
\catcode64 11 % @
\def\TMP@EnsureCode#1#2#3{%
  \edef\PE@AtEnd{%
    \PE@AtEnd
    #1#2 \the#1#2\relax
  }%
  #1#2 #3\relax
}
\TMP@EnsureCode\catcode{0}{12}% ^^@
\TMP@EnsureCode\catcode{34}{12}% "
\TMP@EnsureCode\catcode{39}{12}% '
\TMP@EnsureCode\catcode{42}{12}% *
\TMP@EnsureCode\catcode{45}{12}% -
\TMP@EnsureCode\catcode{46}{12}% .
\TMP@EnsureCode\catcode{47}{12}% /
\TMP@EnsureCode\catcode{60}{12}% <
\TMP@EnsureCode\catcode{61}{12}% =
\TMP@EnsureCode\catcode{62}{12}% >
\TMP@EnsureCode\catcode{94}{7}% ^
\TMP@EnsureCode\catcode{96}{12}% `
\TMP@EnsureCode\uccode{34}{0}% "
\TMP@EnsureCode\uccode{48}{0}% 0
\TMP@EnsureCode\uccode{61}{0}% =
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname detokenize\endcsname\relax
  \long\def\EdefSanitize#1#2{%
    \begingroup
      \csname @safe@activestrue\endcsname
      \edef#1{#2}%
      \PE@onelevel@sanitize#1%
    \expandafter\endgroup
    \expandafter\def\expandafter#1\expandafter{#1}%
  }%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname @onelevel@sanitize\endcsname\relax
    \def\PE@onelevel@sanitize#1{%
      \edef#1{\expandafter\PE@strip@prefix\meaning#1}%
    }%
    \def\PE@strip@prefix#1>{}%
  \else
    \let\PE@onelevel@sanitize\@onelevel@sanitize
  \fi
\else
  \long\def\EdefSanitize#1#2{%
    \begingroup
      \csname @safe@activestrue\endcsname
      \edef#1{#2}%
    \expandafter\endgroup
    \expandafter\def\expandafter#1\expandafter{%
      \detokenize\expandafter{#1}%
    }%
  }%
  \def\PE@onelevel@sanitize#1{%
    \edef#1{\detokenize\expandafter{#1}}%
  }%
\fi
\let\PE@sanitize\EdefSanitize
\begingroup
  \catcode`\ =12\relax%
\def\x{\endgroup\def\PE@space@other{ }}\x\relax
\def\PE@space@space{ }
\def\PE@SanitizeSpaceOther#1{%
  \edef#1{\expandafter\PE@SpaceToOther#1 \relax}%
}
\def\PE@SpaceToOther#1 #2\relax{%
  #1%
  \ifx\\#2\\%
  \else
    \PE@space@other
    \@ReturnAfterFi{%
      \PE@SpaceToOther#2\relax
    }%
  \fi
}
\long\def\@ReturnAfterFi#1\fi{\fi#1}
\def\EdefUnescapeName#1#2{%
  \EdefSanitize#1{#2}%
  \PE@SanitizeSpaceOther#1%
  \PE@UnescapeName#1%
  \PE@onelevel@sanitize#1%
}
\begingroup
  \catcode`\$=6  % hash
  \catcode`\#=12 % other
  \gdef\PE@UnescapeName$1{%
    \begingroup
      \PE@InitUccodeHexDigit
      \def\PE@result{}%
      \expandafter\PE@DeName$1#\relax\relax
    \expandafter\endgroup
    \expandafter\def\expandafter$1\expandafter{\PE@result}%
  }%
  \gdef\PE@DeName$1#$2$3{%
    \ifx\relax$2%
      \edef\PE@result{\PE@result$1}%
      \let\PE@next\relax
    \else
      \ifx\relax$3%
        % wrong escape sequence in input
        \edef\PE@result{\PE@result$1#}%
        \let\PE@next\relax
      \else
        \uppercase{%
          \def\PE@testA{$2}%
          \def\PE@testB{$3}%
        }%
        \ifcase\ifcase\expandafter\PE@TestUcHexDigit\PE@testA
                 \ifcase\expandafter\PE@TestUcHexDigit\PE@testB
                   \z@
                 \else
                   \@ne
                 \fi
               \else
                 \@ne
               \fi
          \uccode\z@="\PE@testA\PE@testB\relax
          \uppercase{%
            \def\PE@temp{^^@}%
          }%
          \uccode\z@=\z@
          \edef\PE@result{\PE@result$1\PE@temp}%
          \let\PE@next\PE@DeName
        \else
          % wrong escape sequence in input
          \edef\PE@result{\PE@result$1#}%
          \def\PE@next{\PE@DeName$2$3}%
        \fi
      \fi
    \fi
    \PE@next
  }%
\endgroup
\def\PE@InitUccodeHexDigit{%
  \uccode`a=`A\relax
  \uccode`b=`B\relax
  \uccode`c=`C\relax
  \uccode`d=`D\relax
  \uccode`e=`E\relax
  \uccode`f=`F\relax
  \uccode`A=\z@
  \uccode`B=\z@
  \uccode`C=\z@
  \uccode`D=\z@
  \uccode`E=\z@
  \uccode`F=\z@
  \uccode`0=\z@
  \uccode`1=\z@
  \uccode`2=\z@
  \uccode`3=\z@
  \uccode`4=\z@
  \uccode`5=\z@
  \uccode`6=\z@
  \uccode`7=\z@
  \uccode`8=\z@
  \uccode`9=\z@
}
\def\PE@TestUcHexDigit#1{%
  \ifnum`#1<48 % 0
    \@ne
  \else
    \ifnum`#1>70 % F
      \@ne
    \else
      \ifnum`#1>57 % 9
        \ifnum`#1<65 % A
          \@ne
        \else
          \z@
        \fi
      \else
        \z@
      \fi
    \fi
  \fi
}
\def\EdefUnescapeString#1#2{%
  \EdefSanitize#1{#2}%
  \PE@SanitizeSpaceOther#1%
  \PE@NormalizeLineEnd#1%
  \PE@UnescapeString#1%
  \PE@onelevel@sanitize#1%
}
\begingroup
  \uccode`\8=10 % lf
  \uccode`\9=13 % cr
\def\x#1#2{\endgroup
  \def\PE@NormalizeLineEnd##1{%
    \def\PE@result{}%
    \expandafter\PE@@NormalizeLineEnd##1#2\relax
    \let##1\PE@result
  }%
  \def\PE@@NormalizeLineEnd##1#2##2{%
    \ifx\relax##2%
      \edef\PE@result{\PE@result##1}%
      \let\PE@next\relax
    \else
      \edef\PE@result{\PE@result##1#1}%
      \ifx#1##2% lf
        \let\PE@next\PE@@NormalizeLineEnd
      \else
        \def\PE@next{\PE@@NormalizeLineEnd##2}%
      \fi
    \fi
    \PE@next
  }%
}%
\uppercase{%
  \x 89%
}
\begingroup
  \catcode`\|=0 %
  \catcode`\\=12 %
  |gdef|PE@UnescapeString#1{%
    |begingroup
      |def|PE@result{}%
      |expandafter|PE@DeString#1\|relax
    |expandafter|endgroup
    |expandafter|def|expandafter#1|expandafter{|PE@result}%
  }%
  |gdef|PE@DeString#1\#2{%
    |ifx|relax#2%
      |edef|PE@result{|PE@result#1}%
      |let|PE@next|relax
    |else
      |if n#2%
        |uccode|z@=10 %
      |else|if r#2%
        |uccode|z@=13 %
      |else|if t#2%
        |uccode|z@=9 %
      |else|if b#2%
        |uccode|z@=8 %
      |else|if f#2%
        |uccode|z@=12 %
      |else
        |uccode|z@=|z@
      |fi|fi|fi|fi|fi
      |ifnum|uccode|z@>|z@
        |uppercase{%
          |edef|PE@temp{^^@}%
        }%
        |edef|PE@result{|PE@result#1|PE@temp}%
        |let|PE@next|PE@DeString
      |else
        |if\#2% backslash
          |edef|PE@result{|PE@result#1}%
          |let|PE@next|PE@CheckEndBackslash
        |else
          |ifnum`#2=10 % linefeed
            |edef|PE@result{|PE@result#1}%
            |let|PE@next|PE@DeString
          |else
            |ifcase|PE@TestOctDigit#2%
              |edef|PE@result{|PE@result#1}%
              |def|PE@next{|PE@OctI#2}%
            |else
              |edef|PE@result{|PE@result#1#2}%
              |let|PE@next|PE@DeString
            |fi
          |fi
        |fi
      |fi
    |fi
    |PE@next
  }%
  |gdef|PE@CheckEndBackslash#1{%
    |ifx|relax#1%
    |else
      |edef|PE@result{|PE@result\}%
      |expandafter|PE@DeString|expandafter#1%
    |fi
  }%
|endgroup
\def\PE@TestOctDigit#1{%
  \ifnum`#1<48 % 0
    \@ne
  \else
    \ifnum`#1>55 % 7
      \@ne
    \else
      \z@
    \fi
  \fi
}
\def\PE@OctI#1#2{%
  \ifcase\PE@TestOctDigit#2%
    \def\PE@next{\PE@OctII{#1#2}}%
  \else
    \def\PE@next{\PE@OctAll#1#2}%
  \fi
  \PE@next
}
\def\PE@OctII#1#2{%
  \ifcase\PE@TestOctDigit#2%
    \def\PE@next{\PE@OctAll{#1#2}}%
  \else
    \def\PE@next{\PE@OctAll{#1}#2}%
  \fi
  \PE@next
}
\def\PE@OctAll#1{%
  \uccode\z@='#1\relax
  \uppercase{%
    \edef\PE@result{\PE@result^^@}%
  }%
  \PE@DeString
}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname RequirePackage\endcsname\relax
  \input pdftexcmds.sty\relax
\else
  \RequirePackage{pdftexcmds}[2007/11/11]%
\fi
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname pdf@escapehex\endcsname\relax
  \long\def\EdefEscapeHex#1#2{%
    \EdefSanitize#1{#2}%
    \PE@SanitizeSpaceOther#1%
    \PE@EscapeHex#1%
  }%
  \def\EdefUnescapeHex#1#2{%
    \EdefSanitize#1{#2}%
    \PE@UnescapeHex#1%
  }%
  \long\def\EdefEscapeName#1#2{%
    \EdefSanitize#1{#2}%
    \PE@SanitizeSpaceOther#1%
    \PE@EscapeName#1%
  }%
  \long\def\EdefEscapeString#1#2{%
    \EdefSanitize#1{#2}%
    \PE@SanitizeSpaceOther#1%
    \PE@EscapeString#1%
  }%
\else
  \long\def\PE@edefbabel#1#2#3{%
    \begingroup
      \csname @save@activestrue\endcsname
      \edef#1{#2{#3}}%
    \expandafter\endgroup
    \expandafter\def\expandafter#1\expandafter{#1}%
  }%
  \long\def\EdefEscapeHex#1#2{%
    \PE@edefbabel#1\pdf@escapehex{#2}%
  }%
  \def\EdefUnescapeHex#1#2{%
    \PE@edefbabel#1\pdf@unescapehex{#2}%
  }%
  \long\def\EdefEscapeName#1#2{%
    \PE@edefbabel#1\pdf@escapename{#2}%
  }%
  \long\def\EdefEscapeString#1#2{%
    \PE@edefbabel#1\pdf@escapestring{#2}%
  }%
  \PE@AtEnd
  \expandafter\endinput
\fi
\edef\PE@hash{\string#}
\begingroup
  \escapechar=-1 %
\edef\x{\endgroup
  \def\noexpand\PE@backslash{\string\\}%
}
\x
\newif\ifPE@etex
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname numexpr\endcsname\relax
\else
  \PE@etextrue
\fi
\ifPE@etex
  \def\PE@EscapeHex#1{%
    \edef#1{\expandafter\PE@ToHex#1\relax}%
  }%
\else
  \def\PE@EscapeHex#1{%
    \def\PE@result{}%
    \expandafter\PE@ToHex#1\relax
    \let#1\PE@result
  }%
\fi
\def\PE@ToHex#1{%
  \ifx\relax#1%
  \else
    \PE@HexChar{#1}%
    \expandafter\PE@ToHex
  \fi
}%
\ifPE@etex
  \def\PE@HexChar#1{%
    \PE@HexDigit{\numexpr\dimexpr.0625\dimexpr`#1sp\relax\relax\relax}%
    \PE@HexDigit{%
      \numexpr`#1-16*\dimexpr.0625\dimexpr`#1sp\relax\relax\relax
    }%
  }%
\else
  \def\PE@HexChar#1{%
    \dimen0=`#1sp%
    \dimen2=.0625\dimen0 %
    \advance\dimen0-16\dimen2 %
    \edef\PE@result{%
      \PE@result
      \PE@HexDigit{\dimen2 }%
      \PE@HexDigit{\dimen0 }%
    }%
  }%
\fi
\def\PE@HexDigit#1{%
  \expandafter\string
  \ifcase#1%
    0\or 1\or 2\or 3\or 4\or 5\or 6\or 7\or 8\or 9\or
    A\or B\or C\or D\or E\or F%
  \fi
}
\ifPE@etex
  \def\PE@OctChar#1{%
    \expandafter\PE@@OctChar
        \the\numexpr\dimexpr.015625\dimexpr`#1sp\relax\relax
            \expandafter\relax
        \expandafter\relax
        \the\numexpr\dimexpr.125\dimexpr`#1sp\relax\relax\relax
        \relax
        #1%
  }%
  \def\PE@@OctChar#1\relax#2\relax#3{%
    \PE@backslash
    #1%
    \the\numexpr#2-8*#1\relax
    \the\numexpr\dimexpr`#3sp\relax-8*#2\relax
  }%
\else
  \def\PE@OctChar#1{%
    \dimen0=`#1sp%
    \dimen2=.125\dimen0 %
    \dimen4=.125\dimen2 %
    \advance\dimen0-8\dimen2 %
    \advance\dimen2-8\dimen4 %
    \edef\PE@result{%
      \PE@result
      \PE@backslash
      \number\dimen4 %
      \number\dimen2 %
      \number\dimen0 %
    }%
  }%
\fi
\def\PE@UnescapeHex#1{%
  \begingroup
    \PE@InitUccodeHexDigit
    \def\PE@result{}%
    \expandafter\PE@DeHex#1\relax\relax
  \expandafter\endgroup
  \expandafter\def\expandafter#1\expandafter{\PE@result}%
}
\def\PE@DeHex#1#2{%
  \ifx#2\relax
    \ifx#1\relax
      \let\PE@next\relax
    \else
      \uppercase{%
        \def\PE@testA{#1}%
      }%
      \ifcase\expandafter\PE@TestUcHexDigit\PE@testA
        \def\PE@next{%
          \PE@DeHex#10\relax\relax
        }%
      \else
        \let\PE@next\relax
      \fi
    \fi
  \else
    \uppercase{%
      \def\PE@testA{#1}%
      \def\PE@testB{#2}%
    }%
    \ifcase\expandafter\PE@TestUcHexDigit\PE@testA
      \ifcase\expandafter\PE@TestUcHexDigit\PE@testB
        \uccode\z@="\PE@testA\PE@testB\relax
        \ifnum\uccode\z@=32 %
          \let\PE@temp\PE@space@space
        \else
          \uppercase{%
            \def\PE@temp{^^@}%
          }%
        \fi
        \edef\PE@result{\PE@result\PE@temp}%
        \let\PE@next\PE@DeHex
      \else
        % invalid input sequence
        \def\PE@next{%
          \PE@DeHex#1%
        }%
      \fi
    \else
      % invalid input sequence
      \def\PE@next{\PE@DeHex#2}%
    \fi
  \fi
  \PE@next
}
\ifPE@etex
  \def\PE@EscapeName#1{%
    \edef#1{\expandafter\PE@EscapeNameTokens#1\relax}%
  }%
\else
  \def\PE@EscapeName#1{%
    \def\PE@result{}%
    \expandafter\PE@EscapeNameTokens#1\relax
    \let#1\PE@result
  }%
\fi
\def\PE@EscapeNameTokens#1{%
  \ifx\relax#1%
  \else
    \ifnum`#1<33 %
      \ifcase`#1 %
        % drop illegal zero
      \else
        \PE@EscapeNameAdd\PE@hash
        \PE@HexChar#1%
      \fi
    \else
      \ifnum`#1>126 %
        \PE@EscapeNameAdd\PE@hash
        \PE@HexChar#1%
      \else  \ifnum`#1=35  \PE@EscapeNameHashChar 23% #
        \else\ifnum`#1=37  \PE@EscapeNameHashChar 25% %
        \else\ifnum`#1=40  \PE@EscapeNameHashChar 28% (
        \else\ifnum`#1=41  \PE@EscapeNameHashChar 29% )
        \else\ifnum`#1=47  \PE@EscapeNameHashChar 2F% /
        \else\ifnum`#1=60  \PE@EscapeNameHashChar 3C% <
        \else\ifnum`#1=62  \PE@EscapeNameHashChar 3E% >
        \else\ifnum`#1=91  \PE@EscapeNameHashChar 5B% [
        \else\ifnum`#1=93  \PE@EscapeNameHashChar 5D% ]
        \else\ifnum`#1=123 \PE@EscapeNameHashChar 7B% {
        \else\ifnum`#1=125 \PE@EscapeNameHashChar 7D% }
        \else
          \PE@EscapeNameAdd{#1}%
        \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
      \fi
    \fi
    \expandafter\PE@EscapeNameTokens
  \fi
}%
\def\PE@EscapeNameHashChar#1#2{%
  \PE@EscapeNameAdd{\PE@hash\string#1\string#2}%
}%
\ifPE@etex
  \def\PE@EscapeNameAdd#1{#1}%
\else
  \def\PE@EscapeNameAdd#1{%
    \edef\PE@result{%
      \PE@result
      #1%
    }%
  }%
\fi
\ifPE@etex
  \def\PE@EscapeString#1{%
    \edef#1{\expandafter\PE@EscapeStringTokens#1\relax}%
  }%
\else
  \def\PE@EscapeString#1{%
    \begingroup
      \def\PE@result{}%
      \expandafter\PE@EscapeStringTokens#1\relax
    \expandafter\endgroup
    \expandafter\def\expandafter#1\expandafter{\PE@result}%
  }%
\fi
\def\PE@EscapeStringTokens#1{%
  \ifx\relax#1%
  \else
    \ifnum`#1<33 %
      \PE@OctChar#1%
    \else
      \ifnum`#1>126 %
        \PE@OctChar#1%
      \else  \ifnum`#1=40 \PE@EscapeStringAdd{\string\(}% (
        \else\ifnum`#1=41 \PE@EscapeStringAdd{\string\)}% )
        \else\ifnum`#1=92 \PE@EscapeStringAdd{\string\\}% \
        \else
          \PE@EscapeStringAdd{#1}%
        \fi\fi\fi
      \fi
    \fi
    \expandafter\PE@EscapeStringTokens
  \fi
}%
\ifPE@etex
  \def\PE@EscapeStringAdd#1{#1}%
\else
  \def\PE@EscapeStringAdd#1{%
    \edef\PE@result{%
      \PE@result
      #1%
    }%
  }%
\fi
\PE@AtEnd
\endinput
%%
%% End of file `pdfescape.sty'.
