%%
%% This is file 'pxjahyper.sty'.
%%
%% Copyright (c) 2012-2021 Takayuki YATO (aka. "ZR")
%%   GitHub:   https://github.com/zr-tex8r
%%   Twitter:  @zr_tex8r
%%
%% This package is distributed under the MIT License.
%%

%% package declaration
\NeedsTeXFormat{pLaTeX2e}
\ProvidesPackage{pxjahyper}[2021/05/29 v0.9b]
\def\pxhy@pkgname{pxjahyper}
\providecommand{\bxDebug}[1]{}

%--------------------------------------- Preparations

%% error messages
\def\pxhy@error{\PackageError\pxhy@pkgname}
\@onlypreamble\pxhy@eh@fatal
\def\pxhy@eh@fatal{%
  Package loading is aborted right now.\MessageBreak\@ehc
}

%% packages
\RequirePackage{ltxcmds}[2011/08/22]% v1.21

%% variables
\newif\ifpxhy@ptex
\newif\ifpxhy@uptex
\newif\ifpxhy@etex
\newif\ifpxhy@etoolbox
\newif\ifpxhy@new@hook@system
\newif\ifpxhy@tounicode
\newif\ifpxhy@uniescape
\newif\ifpxhy@bigcode
\let\pxhy@bigcode@given\relax
\newif\ifpxhy@papersize
\newif\ifpxhy@textcmd
\chardef\pxhy@driver@none=0
\chardef\pxhy@driver@dvipdfmx=1
\chardef\pxhy@driver@dvips=2
\let\pxhy@driver\@undefined
\newif\ifpxhy@hy@unicode
\newif\ifpxhy@jacommentline
\newif\ifpxhy@disablecmds
\newif\ifpxhy@otfutf
\newif\ifpxhy@otfcid
\newif\ifpxhy@otfmacros

%--------------------------------------- Package options

%% DVI drivers
\DeclareOption{dvipdfmx}{%
  \let\pxhy@driver\pxhy@driver@dvipdfmx
}
\DeclareOption{dvipdfm}{%
  \let\pxhy@driver\pxhy@driver@dvipdfmx
}
\DeclareOption{dvips}{%
  \let\pxhy@driver\pxhy@driver@dvips
}
\DeclareOption{nodvidriver}{%
  \let\pxhy@driver\pxhy@driver@none
}
%% modes
\DeclareOption{none}{%
  \let\pxhy@driver\pxhy@driver@none %FIXME
}
\DeclareOption{auto}{%
  \let\pxhy@driver\@undefined %FIXME
}
\DeclareOption{tounicode}{%
  \pxhy@tounicodetrue
}
\DeclareOption{notounicode}{%
  \pxhy@tounicodefalse
}
\DeclareOption{out2uni}{%
  \pxhy@uniescapetrue
}
\DeclareOption{noout2uni}{%
  \pxhy@uniescapefalse
  \let\pxhy@nouniescape@given=t
}
\DeclareOption{convbkmk}{%
  \pxhy@uniescapetrue
}
\DeclareOption{noconvbkmk}{%
  \pxhy@uniescapefalse
  \let\pxhy@nouniescape@given=t
}
%% others
\DeclareOption{papersize}{%
  \pxhy@papersizetrue
}
\DeclareOption{nopapersize}{%
  \pxhy@papersizefalse
}
\pxhy@bigcodetrue
\DeclareOption{bigcode}{%
  \pxhy@bigcodetrue
  \let\pxhy@bigcode@given=t
}
\DeclareOption{nobigcode}{%
  \pxhy@bigcodefalse
}
\DeclareOption{jacommentline}{%
  \pxhy@jacommentlinetrue
}
\DeclareOption{nojacommentline}{%
  \pxhy@jacommentlinefalse
}
\DeclareOption{disablecmds}{%
  \pxhy@disablecmdstrue
}
\DeclareOption{nodisablecmds}{%
  \pxhy@disablecmdsfalse
}
\DeclareOption{otfutf}{%
  \pxhy@otfutftrue
}
\DeclareOption{nootfutf}{%
  \pxhy@otfutffalse
}
\DeclareOption{otfcid}{%
  \pxhy@otfcidtrue
}
\DeclareOption{nootfcid}{%
  \pxhy@otfcidfalse
}
\pxhy@otfmacrostrue
\DeclareOption{otfmacros}{%
  \pxhy@otfmacrostrue
  \let\pxhy@otfmacros@given=t
}
\DeclareOption{nootfmacros}{%
  \pxhy@otfmacrosfalse
}
\DeclareOption{force-unicode}{%
  \let\pxhy@force@unicode=t
}
%% dispatch
\ExecuteOptions{%
  auto,tounicode,papersize,jacommentline,disablecmds,otfutf,otfcid%
}
\ProcessOptions*

%--------------------------------------- Environment check

%% The hyperref package must be loaded in advance.
\@ifpackageloaded{hyperref}{}{%else
  \pxhy@error{Package 'hyperref' is not yet loaded}
   {\pxhy@eh@fatal}%
  \endinput
}

%% Check for the hyperref option 'unicode'.
\expandafter\ifx\csname ifHy@unicode\expandafter\endcsname
    \csname iftrue\endcsname
  \pxhy@hy@unicodetrue
\fi
\AtBeginDocument{%
  \@tempswafalse
  \expandafter\ifx\csname ifHy@unicode\expandafter\endcsname
      \csname iftrue\endcsname
    \@tempswatrue
  \fi
  \ifnum0\ifpxhy@hy@unicode1\fi\if@tempswa1\fi=1
    \PackageError\pxhy@pkgname
     {You must not change the encoding setting of hyperref\MessageBreak
      (e.g. 'unicode') after pxjahyper is loaded}%
     {\@ehc}%
  \fi
}

%% Check hyperref driver.
\ifx\pxhy@driver\@undefined
  \let\pxhy@driver\pxhy@driver@none
  \def\pxhy@tmpa{hdvipdfm}
  \ifx\Hy@driver\pxhy@tmpa
    \let\pxhy@driver\pxhy@driver@dvipdfmx
  \fi
  \def\pxhy@tmpa{hdvips}
  \ifx\Hy@driver\pxhy@tmpa
    \let\pxhy@driver\pxhy@driver@dvips
  \fi
\fi

%% Check the engine.
\@onlypreamble\pxhy@check
\def\pxhy@check#1#2{%
  \edef\pxhy@tmpa{\string#1}%
  \edef\pxhy@tmpb{\meaning#1}%
  \ifx\pxhy@tmpa\pxhy@tmpb #2\fi
}
\pxhy@check\eTeXversion{%
  \pxhy@etextrue
  \IfFileExists{etoolbox.sty}{\pxhy@etoolboxtrue}{}%
}
\pxhy@check\kanjiskip{\pxhy@ptextrue}
\pxhy@check\forcecjktoken{\pxhy@uptextrue}
\ifpxhy@ptex\else
  \pxhy@error{Unknown engine used}%
   {\pxhy@eh@fatal}
  \expandafter\endinput
\fi

%% Check for the new hook system.
\@ifl@t@r\fmtversion{2020/10/01}{\pxhy@new@hook@systemtrue}{}

%% adjustment
% upTeX not in unicode is not seen as upTeX.
\ifnum\jis"2121="3000 \else
  \pxhy@uptexfalse
\fi
% bigcode cannot be used without upTeX.
\ifpxhy@bigcode \ifpxhy@uptex\else
  \pxhy@bigcodefalse
  \ifx t\pxhy@bigcode@given
    \PackageWarningNoLine\pxhy@pkgname
     {bigcode is invalid without upTeX}
  \fi
\fi\fi
%% pxhy@papersize switch
\ifnum\pxhy@driver=\pxhy@driver@none
  \pxhy@papersizefalse
\fi
%% pxhy@textcmd switch
\ifnum\pxhy@driver=\pxhy@driver@none
  \pxhy@textcmdfalse
\else
  \pxhy@textcmdtrue
\fi
%% pxhy@uniescape switch
\ifnum\pxhy@driver=\pxhy@driver@dvips \ifx t\pxhy@nouniescape@given\else
  \pxhy@uniescapetrue
\fi\fi

% hyperref 'unicode' is allowed only on upLaTeX.
\ifnum0\ifpxhy@hy@unicode\ifpxhy@uptex\else
    \ifx t\pxhy@force@unicode\else1\fi\fi\fi>\z@
  \PackageError\pxhy@pkgname
   {The hyperref 'unicode' mode is not supported\MessageBreak
    on the pTeX engine}%
   {\pxhy@eh@fatal}%
  \expandafter\endinput
\fi
\ifpxhy@hy@unicode
  \pxhy@uniescapefalse
  \pxhy@otfutftrue
\fi
% otfmacros requires upTeX or out2uni.
\ifpxhy@uptex\else\ifpxhy@uniescape\else\ifpxhy@hy@unicode\else
  \pxhy@otfmacrosfalse
  \ifx t\pxhy@otfmacros@given
    \PackageWarningNoLine\pxhy@pkgname
     {Option 'otfmacros' is invalid\MessageBreak
      unless upTeX is used or 'out2uni' is specified}
  \fi
\fi\fi\fi
% otfcid requrires otfutf.
\ifpxhy@otfutf \else \ifpxhy@otfcid
  \PackageInfo\pxhy@pkgname
   {Option 'nootfcid' is assumed\MessageBreak
    because 'nootfutf' is effective\@gobble}
  \pxhy@otfcidfalse
\fi\fi
% otfmacros requrires otfcid.
\ifpxhy@otfcid \else \ifpxhy@otfmacros
  \PackageInfo\pxhy@pkgname
   {Option 'nootfmacros' is assumed\MessageBreak
    because 'nootfcid' is effective\@gobble}
  \pxhy@otfmacrosfalse
\fi\fi

\bxDebug{****pxjahyper env^^J%
pxhy@ptex = \ifpxhy@ptex true\else false\fi^^J%
pxhy@uptex = \ifpxhy@uptex true\else false\fi^^J%
pxhy@etex = \ifpxhy@etex true\else false\fi^^J%
pxhy@etoolbox = \ifpxhy@etoolbox true\else false\fi^^J%
pxhy@new@hook@system = \ifpxhy@new@hook@system true\else false\fi^^J%
ifpxhy@hy@unicode = \ifpxhy@hy@unicode true\else false\fi^^J%
pxhy@bigcode = \ifpxhy@bigcode true\else false\fi^^J%
pxhy@driver = \the\pxhy@driver^^J%
pxhy@tounicode = \ifpxhy@tounicode true\else false\fi^^J%
pxhy@uniescape = \ifpxhy@uniescape true\else false\fi^^J%
pxhy@papersize = \ifpxhy@papersize true\else false\fi^^J%
pxhy@textcmd = \ifpxhy@textcmd true\else false\fi^^J%
}

%--------------------------------------- Helpers

%% unique tokens
\def\pxhy@end{\pxhy@end@}
\def\pxhy@mt{\pxhy@mt@}
\let\pxhy@mk\indent % unexpandable

%% \pxhy@begin@dvi@hook{<text>}
\ifpxhy@new@hook@system
  \def\pxhy@begin@dvi@hook#1{%
    \AddToHook{shipout/firstpage}{#1}%
  }
  \DeclareHookRule{shipout/firstpage}{.}{>}{hyperref}
\else
  \RequirePackage{atbegshi}[2011/10/05]% v1.16
  \def\pxhy@begin@dvi@hook#1{%
    \AtBeginShipoutFirst{#1}%
  }
\fi

%% \pxhy@get@jchar{<num>}
% Let \pxhy@jchar a macro expanding to a single jchar token
% of the char code <num>.
\def\pxhy@get@jchar#1{%
  \begingroup
    \pxhy@forcecjktoken
    \kansujichar\@ne=#1\relax
    \xdef\pxhy@jchar{\kansuji\@ne}%
  \endgroup
}

%% \pxhy@forcecjktoken
\ifpxhy@uptex
  \let\pxhy@forcecjktoken\forcecjktoken
\else
  \let\pxhy@forcecjktoken\relax
\fi

%% \pxhy@geta : GETA MARK
\pxhy@get@jchar{\jis"222E}
\let\pxhy@geta\pxhy@jchar

%% \pxhy@hook@after@package{<package-name>}{<code>}
\@onlypreamble\pxhy@hook@after@package
\def\pxhy@hook@after@package#1#2{%
  \ifpxhy@new@hook@system
    \@ifpackageloaded{#1}{#2}{%
      \AddToHook{package/after/#1}{#2}%
    }%
  \else
    \AtBeginDocument{%
      \@ifpackageloaded{#1}{#2}{}%
    }%
  \fi
}

%% \pxhy@triexpandafter
\def\pxhy@triexpandafter{%
  \expandafter\expandafter\expandafter
}

%% \pxhy@cond\ifXXX<arg>\fi{<true>}{<false>}
% Does the test "\ifXXX<arg>", with immediate exit from the
% induced if-level.
\@gobbletwo\if\if \def\pxhy@cond#1\fi{%
  #1\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
}

%--------------------------------------- Helpers (e-TeX)
\ifpxhy@etex

%% packages
\ifpxhy@etoolbox
  \RequirePackage{etoolbox}[2011/01/03]%v2.1
\fi

%% \pxhy@if@star{<varient>}{<normal>}
% Expands to <varient> if followed by *, otherwise to <normal>.
\def\pxhy@if@star#1#2#3{% #3=next-arg
  \expandafter\pxhy@if@star@a\expandafter @\detokenize{#3}@%
      {#1}@*@{#2{#3}}\pxhy@mk
}
\def\pxhy@if@star@a#1@*@#2#3\pxhy@mk{#2}

%% \pxhy@if@opt{<true>}{<false>}
% Expands to <true>{<opt>} if followed by [<opt>], otherwise to <false>.
\def\pxhy@if@opt#1#2#3{% #3=next-arg
  \expandafter\pxhy@if@opt@a\expandafter @\detokenize{#3}@%
      {\pxhy@if@opt@b{#1}}@[@{#2{#3}}\pxhy@mk%]
}
\def\pxhy@if@opt@a#1@[@#2#3\pxhy@mk{#2}
\def\pxhy@if@opt@b#1#2]{#1{#2}}

\fi
%--------------------------------------- Output 'tounicode' special
\ifpxhy@tounicode

  \ifnum\pxhy@driver=\pxhy@driver@dvipdfmx %<*dvipdfmx>
    %% dvipdfmx
    \RequirePackage{pxjahyper-enc}[]%
    \ifpxhy@bigcode\else \suppressbigcode \fi
  \fi                           %</dvipdfmx>

\fi
%--------------------------------------- Papersize special adjustment
\ifpxhy@papersize               %<*papersize>

% When the magnification is in effect (i.e. \mag<>1000), hyperref
% emits a papersize special with wrong value. (dvipdfmx interprets
% the lengths in the special as 'true' length.) So here a papersize
% special with adjusted values will be output.
\ifnum\mag=1000 \else
  \expandafter\ifx\csname ifHy@setpagesize\expandafter\endcsname
   \csname iftrue\endcsname % hyperref setpagesize is on
    \ifnum0<\mag \ifnum32768>\mag % \mag is in valid range
      \begingroup
        \@ifundefined{stockwidth}{}{%else
          \paperwidth=\stockwidth
          \paperheight=\stockheight
        }%
        \@tempcnta=\mag \advance\@tempcnta100000
        \def\pxhy@next1#1#2#3#4#5\relax{%
          \def\pxhy@tmpa{#1#2.#3#4#5}%
        }%
        \expandafter\pxhy@next\the\@tempcnta\relax
        \paperwidth=\pxhy@tmpa\paperwidth
        \paperheight=\pxhy@tmpa\paperheight
        \edef\pxhy@tmpa{%
          \noexpand\pxhy@begin@dvi@hook{%
            \special{papersize=\the\paperwidth,\the\paperheight}}%
        }\pxhy@tmpa
      \endgroup
    \fi\fi
  \fi
\fi

\fi                             %</papersize>
%--------------------------------------- Code input processor

%% constants
\def\pxhy@uc@REPL{FFFD}
\def\pxhy@uc@XNAC{FDD1} % not-a-char codepoint used as marker

%% switch 'pxhy@utfXVI'
% Whether or not to convert to UTF-16.
\newif\ifpxhy@utfXVI

%% Generate tables
% - \pxhy@qh/XY -> Z ; \pxhy@hq/Z -> XY
%   means XY (base-4) = Z (base-16)
% - \pxhy@lhq/ZW -> XY
%   ZW (base-16) - 1 = XY (base-4)
% - \pxhy@hd/X
%   uppercase of X if X is a (lower/uppercase) hexadecimal
%   digit; otherwise undefined
\def\pxhy@next#1#2#3#4#5{%
  \@namedef{pxhy@qh/#1#2}{#3}%
  \@namedef{pxhy@hq/#3}{#1#2}%
  \@namedef{pxhy@lhq/#4#5}{#1#2}%
}
\@for\pxhy@tmpa:={%
  00001,01102,02203,03304,10405,11506,12607,13708,%
  20809,2190A,22A0B,23B0C,30C0D,31D0E,32E0F,33F10}\do{%
  \expandafter\pxhy@next\pxhy@tmpa
}
\def\pxhy@next#1{%
  \lowercase{\def\pxhy@tmpb{#1}}%
  \@namedef{pxhy@hd/#1}{#1}%
  \@namedef{pxhy@hd/\pxhy@tmpb}{#1}%
}
\@tfor\pxhy@tmpa:=0123456789ABCDEF\do{%
  \expandafter\pxhy@next\pxhy@tmpa
}

%% \pxhy@burst-`>...
\let\pxhy@burst\romannumeral

%% \pxhy@uchex{<hex>}
% "Distills" the code-value input. If the input is a hex notation of
% a valid code point of Unicode, then it passes the value to
% \pxhy@uchex@out in zero-padded 4-6 digits; otherwise passes FFFD
% to \pxhy@uchex@out.
% Moreover, when the switch pxhy@utfXVI is true, then conversion into
% UTF-16 is performed and each unit is passed to \pxhy@uchex@out
% in zero-padded 4 digits.
\def\pxhy@uchex#1{%
  \pxhy@uchex@pre@a#1\relax{}\pxhy@mk\pxhy@end
}
\def\pxhy@uchex@pre@a{%
  \expandafter\pxhy@uchex@pre@b\pxhy@burst-`>%
}
\def\pxhy@uchex@pre@b#1#{%
  \pxhy@cond \ifx\pxhy@mt#1\pxhy@mt \fi{%
    \pxhy@uchex@bombout
  }{%else
    \pxhy@uchex@pre@c#1%
  }%
}
\def\pxhy@uchex@pre@c#1{%
  \pxhy@cond \ifx#1\relax \fi{%
    \pxhy@uchex@pre@end
  }{%else
    \pxhy@triexpandafter\pxhy@uchex@pre@d
        \csname pxhy@hd/\string#1\endcsname
  }%
}
\def\pxhy@uchex@pre@d#1{%
  \pxhy@cond \ifx#1\relax \fi{%
    \pxhy@uchex@bombout
  }{%else
    \pxhy@uchex@pre@e#1%
  }%
}
\def\pxhy@uchex@pre@e#1#2\pxhy@mk#3\pxhy@end{%
  \pxhy@cond \if 0#1\fi{%
    \pxhy@cond \ifx\pxhy@mt#3\pxhy@mt \fi{%
      \pxhy@uchex@pre@a#2\pxhy@mk#3\pxhy@end
    }{%else
      \pxhy@uchex@pre@a#2\pxhy@mk#3#1\pxhy@end
    }%
  }{%else
    \pxhy@uchex@pre@a#2\pxhy@mk#3#1\pxhy@end
  }%
}
\def\pxhy@uchex@pre@end#1\pxhy@mk#2\pxhy@end{%
  \pxhy@cond \ifx\pxhy@mt#1\pxhy@mt \fi{%
    \pxhy@uchex@sw{#2}%
  }{%else
    \pxhy@uchex@error
  }%
}
\def\pxhy@uchex@bombout#1\pxhy@end{%
  \pxhy@uchex@error
}

\def\pxhy@uchex@sw#1{%
  \pxhy@cond \ifnum"0#1>"10FFFF \fi{%
    \pxhy@uchex@error
  }{\pxhy@cond \ifnum"0#1>"FFFF \fi{%
    \pxhy@cond \ifpxhy@utfXVI \fi{%
      \pxhy@uchex@big#1"000000\pxhy@end
    }{%else
      \pxhy@uchex@out{#1}%
    }%
  }{%else
    \pxhy@uchex@small#1"0000\pxhy@end
  }}%
}
\def\pxhy@uchex@small#1#2#3#4#5#6\pxhy@end{%
  \pxhy@uchex@small@a#1#2#3#4#5\pxhy@end
}
\def\pxhy@uchex@small@a#1"#2\pxhy@end{%
  \pxhy@uchex@out{#2#1}%
}
\def\pxhy@uchex@big#1#2#3#4#5#6#7#8\pxhy@end{%
  \pxhy@uchex@big@a#1#2#3#4#5#6#7\pxhy@end
}
\def\pxhy@uchex@big@a#1"#2\pxhy@end{%
  \pxhy@uchex@big@b#2#1\pxhy@end
}
\def\pxhy@uchex@big@b#1#2#3#4{%
  \pxhy@triexpandafter\pxhy@uchex@big@c
      \csname pxhy@lhq/#1#2\pxhy@triexpandafter\endcsname
      \csname pxhy@hq/#3\pxhy@triexpandafter\endcsname
      \csname pxhy@hq/#4\endcsname
}
\def\pxhy@uchex@big@c#1#2#3#4#5#6{%
  \pxhy@triexpandafter\pxhy@uchex@big@d
      \csname pxhy@qh/2#1\pxhy@triexpandafter\endcsname
      \csname pxhy@qh/#2#3\pxhy@triexpandafter\endcsname
      \csname pxhy@qh/#4#5\pxhy@triexpandafter\endcsname
      \csname pxhy@qh/3#6\endcsname
}
\def\pxhy@uchex@big@d#1#2#3#4#5\pxhy@end{%
  \pxhy@uchex@out{D#1#2#3}%
  \pxhy@uchex@out{D#4#5}%
}
\edef\pxhy@uchex@error{%
  \noexpand\pxhy@uchex@out{\pxhy@uc@REPL}%
}

%--------------------------------------- Hooks to pdfstringdef

%% variables
\let\pxhy@str\relax

%% \pxhy@Ux
% The definition of \Ux in PDF strings.
\let\pxhy@Ux\@undefined

\ifpxhy@hy@unicode              %<*unicode>

  %% \pxhy@Ux
  \def\pxhy@Ux{\pxhy@uchex}%
  \pxhy@utfXVIfalse
  \def\pxhy@uchex@out#1{%
    \unichar{"#1}%
  }

\else\ifpxhy@uptex              %<*upTeX>

  %% \pxhy@Ux
  \def\pxhy@Ux{\pxhy@uchex}%
  \pxhy@utfXVIfalse

  %% \pxhy@marker: a not-a-char U+FDD1
  \pxhy@get@jchar{\ucs"\pxhy@uc@XNAC}
  \edef\pxhy@marker{\pxhy@jchar}

  %BEGIN-- in the following block #1 means the marker
  \def\pxhy@next#1{% #1=marker
    %% \pxhy@uchex@out
    % Expands to a tag string which will later be converted to
    % a real character in the postprocess.
    \def\pxhy@uchex@out##1{#1##1>}%
    %% \pxhy@posthook
    % The postprocess of this package. It is registered to
    % \pdfstringdefPostHook.
    \def\pxhy@posthook##1{%
      \expandafter\pxhy@posthook@a##1#1\pxhy@end
      \pxhy@posthook@b##1%
    }%
    \def\pxhy@posthook@a##1#1##2\pxhy@end{%
      \ifx\pxhy@mt##2\pxhy@mt
        \expandafter\@gobbletwo
      \fi
    }%
    \def\pxhy@posthook@b##1{%
      \let\pxhy@str\@empty
      \expandafter\pxhy@posthook@c##1#1>%
      \global\let##1=\pxhy@str
    }%
    \def\pxhy@posthook@c##1#1##2>{%
      \ifx\pxhy@mt##2\pxhy@mt
        \edef\pxhy@str{\pxhy@str##1}%
      \else
        \pxhy@get@jchar{"##2}%
        \edef\pxhy@str{\pxhy@str##1\pxhy@jchar}%
        \expandafter\pxhy@posthook@c
      \fi
    }%
  }
  \expandafter\pxhy@next\pxhy@marker
  %END--

  % Add \pxhy@posthook to \pdfstringdefPostHook.
  \begingroup
    \toks@\expandafter{\pdfstringdefPostHook{#1}}
    \edef\pxhy@next{%
      \gdef\noexpand\pdfstringdefPostHook##1{%
        \the\toks@
        \noexpand\pxhy@posthook{##1}%
      }%
    }%
    \pxhy@next
  \endgroup

\fi\fi                          %</>

\ifpxhy@uniescape               %<*uniescape>

  %% \pxhy@Ux
  \def\pxhy@Ux{\pxhy@uchex}%
  % \pxhy@uchex converts to UTF-16
  \pxhy@utfXVItrue
  \def\pxhy@uchex@out#1{%
    % Expands to \0x form.
    \0x#1%
  }

\fi                             %</uniescape>

%% Makes \Ux be the code input command in PDF strings.
\ifx\pxhy@Ux\@undefined\else
  \pdfstringdefDisableCommands{%
    \let\Ux\pxhy@Ux
    % bxbase
    \let\bxUx\pxhy@Ux
    \let\bxUI\pxhy@Ux
  }
\fi

%--------------------------------------- Support for 'otfutf'
\ifpxhy@otfutf

%% \pxhy@UTF
% The definition of \UTF in PDF strings.
\ifx\pxhy@Ux\@undefined
  % Use a fallback definition.
  \def\pxhy@UTF{\pxhy@uchex}
  \pxhy@utfXVIfalse
  \def\pxhy@uchex@out#1{%
    \@nameuse{U+#1}% issue a warning
    \pxhy@geta
  }
\else
  \let\pxhy@UTF\pxhy@Ux
\fi

%% \pxhy@dispatch@otfutf
\@onlypreamble\pxhy@dispatch@otfutf
\def\pxhy@dispatch@otfutf{%
  \global\let\pxhy@dispatch@otfutf\relax
  \pdfstringdefDisableCommands{%
    \let\UTF\pxhy@UTF
    \let\UTFM\pxhy@UTF
    \let\UTFK\pxhy@UTF
    \let\UTFC\pxhy@UTF
    \let\UTFT\pxhy@UTF
    % pxbabel
    \let\pxUTFJ\pxhy@UTF
  }
}

%% enable hooks
\pxhy@hook@after@package{otf}{\pxhy@dispatch@otfutf}

\fi
%--------------------------------------- Support for 'otfcid'
\ifpxhy@otfcid

%% \pxhy@otfcid@disabled
% Holds the message if otfcid/otfmacros is unavailable;
% otherwise equals to \relax.
\@onlypreamble\pxhy@otfcid@disabled
\let\pxhy@otfcid@disabled\relax
\ifpxhy@etoolbox
  % check if bxjatoucs is available
  \IfFileExists{bxjatoucs.sty}{%
    \let\bxjatoucsCheckAvail=t
    \RequirePackage{bxjatoucs}[]
    \undef\bxjatoucsCheckAvail
  }{}
  \ifundef\bxjaCidToUcs{%
    \def\pxhy@otfcid@disabled{%
      package 'bxjatoucs' is unavailable%
    }%
  }{}
\else\ifpxhy@etex
  \def\pxhy@otfcid@disabled{%
    package 'etoolbox' is unavailable%
  }
\else
  \def\pxhy@otfcid@disabled{%
    e-TeX extension is unavailable%
  }
\fi\fi

%% annihilate the ajmacros's own pdfstring process
\ifpxhy@otfmacros\ifx\pxhy@otfcid@disabled\relax
  \let\ajRedefine@ajCommands\relax
\fi\fi

%% \pxhy@CID{<cid>}
\def\pxhy@CID#1{%
  \expandafter\expandafter\expandafter\pxhy@cid@aux
      \bxjaCidToUcsHex{#1}\pxhy@mk{\detokenize{#1}}%
}
%% \pxhy@fast@CID{<cid>}
\def\pxhy@fast@CID#1{%
  \expandafter\expandafter\expandafter\pxhy@cid@aux
      \bxjaFastCidToUcsHex{#1}\pxhy@mk{\number#1}%
}
\ifx\pxhy@Ux\@undefined
  \def\pxhy@cid@aux#1\pxhy@mk#2{%
    \@nameuse{CID+#2}% issue a warning
    \pxhy@geta
  }
\else
\def\pxhy@cid@aux#1\pxhy@mk#2{%
  \ifnum"#1>\z@
    \pxhy@Ux{#1}%
  \else
    \@nameuse{CID+#2}%
    %\pxhy@geta %FIXME: future change
  \fi
}
\fi

%% \pxhy@dispatch@otfcid
\@onlypreamble\pxhy@dispatch@otfcid
\def\pxhy@dispatch@otfcid{%
  \global\let\pxhy@dispatch@otfcid\relax
  \ifx\pxhy@otfcid@disabled\relax % available!
    \pdfstringdefDisableCommands{%
      \let\CID\pxhy@CID
    }%
  \else
    \PackageWarningNoLine\pxhy@pkgname
     {Option 'otfcid'/'otfmacros' is disabled, because\MessageBreak
      \pxhy@otfcid@disabled}%
    \pxhy@otfcidfalse
  \fi
}

%% \pxhy@dispatch@otfmacros
\@onlypreamble\pxhy@dispatch@otfmacros
\def\pxhy@dispatch@otfmacros{%
  \global\let\pxhy@dispatch@otfmacros\relax
  \ifx\pxhy@otfcid@disabled\relax % available!
      \let\ajRedefine@ajCommands\relax
      \chardef\pxhy@tmp@orgcc=\catcode`\@
      \makeatletter
      \InputIfFileExists{pxjahyper-ajm.def}{%
        \PackageInfo\pxhy@pkgname
         {Loaded 'pxjahyper-ajm.def'\@gobble}%
      }{%
        \PackageWarning\pxhy@pkgname
         {File 'pxjahyper-ajm.def' not found\@gobble}%
      }%
      \catcode`\@=\pxhy@tmp@orgcc
  \else \pxhy@otfmacrosfalse
  \fi
}

%% enable hooks
\pxhy@hook@after@package{otf}{\pxhy@dispatch@otfcid}
\ifpxhy@otfmacros
  \pxhy@hook@after@package{ajmacros}{\pxhy@dispatch@otfmacros}
\fi

\fi
%--------------------------------------- Redefine text commands for PD1

%% \pxhy@pdfenc
\edef\pxhy@pdfenc{%
  \ifpxhy@hy@unicode PU\else PD1\fi
}

\ifpxhy@textcmd                 %<*textcmd>

%%<+> \pxDeclarePdfTextCommand{\CS}{<jis>}{<ucs>}
\@onlypreamble\pxDeclarePdfTextCommand
\newcommand*\pxDeclarePdfTextCommand[3]{%
  \pxhy@decl@pdf@tc{#2}{#3}%
   {\DeclareTextCommand{#1}{\pxhy@pdfenc}}%
   {\pxhy@revoke@pdf@tc{#1}}%
}

%%<+> \pxDeclarePdfTextComposite{\CS}{<arg>}{<jis>}{<ucs>}
\@onlypreamble\pxDeclarePdfTextComposite
\newcommand*\pxDeclarePdfTextComposite[4]{%
  \pxhy@decl@pdf@tc{#3}{#4}%
   {\DeclareTextCompositeCommand{#1}{\pxhy@pdfenc}{#2}}%
   {\pxhy@revoke@pdf@tcc{#1}{#2}}%
}

\else                           %<*!textcmd>

\@onlypreamble\pxDeclarePdfTextCommand
\newcommand*\pxDeclarePdfTextCommand[3]{}
\@onlypreamble\pxDeclarePdfTextComposite
\newcommand*\pxDeclarePdfTextComposite[4]{}

\fi                             %</textcmd>

%% \pxhy@revoke@pdf@tc
\@onlypreamble\pxhy@revoke@pdf@tc
\def\pxhy@revoke@pdf@tc#1{%
  \expandafter\let\csname\pxhy@pdfenc\string#1\endcsname\@undefined
  \pxhy@make@txtcmd\pxhy@tmpa{\pxhy@pdfenc}#1%
  \ifx#1\pxhy@tmpa
    \pxhy@make@txtcmd#1?#1%
  \fi
}
\@onlypreamble\pxhy@make@txtcmd
\def\pxhy@make@txtcmd#1#2#3{%
  \expandafter\def\expandafter#1\expandafter{%
    \csname#2-cmd\expandafter\endcsname\expandafter#3%
        \csname#2\string#3\endcsname
  }%
}

%% \pxhy@revoke@pdf@tcc
\@onlypreamble\pxhy@revoke@pdf@tc
\def\pxhy@revoke@pdf@tcc#1#2{%
  \expandafter\let\csname\@backslashchar\pxhy@pdfenc
   \string#1-\string#2\endcsname\@undefined
}

%% \pxhy@decl@pdf@tc
\@onlypreamble\pxhy@decl@pdf@tc
\def\pxhy@decl@pdf@tc#1#2{%
  \pxhy@get@body{#1}{#2}%
  \ifx\pxhy@body\@undefined
    \let\pxhy@next\@secondoftwo
  \else
    \def\pxhy@next{%
      \expandafter\pxhy@decl@pdf@tc@a\pxhy@body\pxhy@end}%
  \fi
  \pxhy@next
}
\@onlypreamble\pxhy@decl@pdf@tc@a
\def\pxhy@decl@pdf@tc@a#1\pxhy@end#2#3{%
  #2{#1}%
}

%% \pxhy@get@body{<jis>}{<ucs>}
\@onlypreamble\pxhy@get@body
\ifpxhy@uptex                   %<*upTeX>
  \def\pxhy@get@body#1#2{%
    \pxhy@get@jchar{\ucs"#2}%
    \let\pxhy@body\pxhy@jchar
  }%
\else                           %<*!upTeX>
  \ifpxhy@uniescape
    \def\pxhy@get@body#1#2{%
      \ifx\pxhy@end#1\pxhy@end
        \def\pxhy@body{\0x#2}%
      \else
        \pxhy@get@jchar{\jis"#1}%
        \let\pxhy@body\pxhy@jchar
      \fi
    }%
  \else
    \def\pxhy@get@body#1#2{%
      \ifx\pxhy@end#1\pxhy@end
        \let\pxhy@body\@undefined
      \else
        \pxhy@get@jchar{\jis"#1}%
        \let\pxhy@body\pxhy@jchar
      \fi
    }%
  \fi
\fi                             %</upTeX>

%%%%%%%%%%%%%%%%%%%% the definitions
\ifpxhy@hy@unicode\else         %<!*unicode>

% JIS X 0213 does not distinguish the following pairs:
%  - circumflex(U+02C6) and asciicircum(U+005E)
%  - tilde(U+02DC) and asciitilde(U+007E)
% Here I use ASCII characters as done in JIS.
\DeclareTextCommand{\textcircumflex}{PD1}{\136}
\DeclareTextCommand{\textasciicircum}{PD1}{\136}
\DeclareTextCommand{\texttilde}{PD1}{\176}
\DeclareTextCommand{\textasciitilde}{PD1}{\176}

% Some ad-hoc redefinitions.
\DeclareTextCommand{\textfi}{PD1}{fi}
\DeclareTextCommand{\textfl}{PD1}{fl}
\DeclareTextCommand{\IJ}{PD1}{IJ}% needed?
\DeclareTextCommand{\ij}{PD1}{ij}% needed?
\DeclareTextCommand{\textspace}{PD1}{\040}
\DeclareTextCommand{\textquotesingle}{PD1}{\047}

%% Some adjustments on accents.
\DeclareTextAccent{\H}{PD1}{\texthungarumlaut}
\DeclareTextCompositeCommand{\H}{PD1}{\@empty}{\texthungarumlaut}
\DeclareTextCompositeCommand{\H}{PD1}{\ }{\texthungarumlaut}
\DeclareTextAccent{\u}{PD1}{\textasciibreve}
\DeclareTextCompositeCommand{\u}{PD1}{\@empty}{\textasciibreve}
\DeclareTextCompositeCommand{\u}{PD1}{\ }{\textasciibreve}
\DeclareTextAccent{\k}{PD1}{\textogonek}
\DeclareTextCompositeCommand{\k}{PD1}{\@empty}{\textogonek}
\DeclareTextCompositeCommand{\k}{PD1}{\ }{\textogonek}

%%[A] The characters in PdfDocEncoding (except ASCII).
\pxDeclarePdfTextCommand{\textasciibreve}{}{02D8}
\pxDeclarePdfTextCommand{\textasciicaron}{}{02C7}
\pxDeclarePdfTextCommand{\textdotaccent}{}{02D9}
\pxDeclarePdfTextCommand{\texthungarumlaut}{}{02DD}
\pxDeclarePdfTextCommand{\textogonek}{}{02DB}
\pxDeclarePdfTextCommand{\textring}{}{02DA}
\pxDeclarePdfTextCommand{\texttilde}{}{02DC}
\pxDeclarePdfTextCommand{\textbullet}{}{2022}
\pxDeclarePdfTextCommand{\textdagger}{2277}{2020}
\pxDeclarePdfTextCommand{\textdaggerdbl}{2278}{2021}
\pxDeclarePdfTextCommand{\textellipsis}{2144}{2026}
\pxDeclarePdfTextCommand{\textemdash}{213D}{2014}
\pxDeclarePdfTextCommand{\textendash}{}{2013}
\pxDeclarePdfTextCommand{\textflorin}{}{0192}
\pxDeclarePdfTextCommand{\textfractionsolidus}{}{2044}
\pxDeclarePdfTextCommand{\guilsinglleft}{}{2039}
\pxDeclarePdfTextCommand{\guilsinglright}{}{203A}
\pxDeclarePdfTextCommand{\textminus}{215D}{2212}
\pxDeclarePdfTextCommand{\textperthousand}{2273}{2030}
\pxDeclarePdfTextCommand{\quotedblbase}{}{201E}
\pxDeclarePdfTextCommand{\textquotedblleft}{2148}{201C}
\pxDeclarePdfTextCommand{\textquotedblright}{2149}{201D}
\pxDeclarePdfTextCommand{\textquoteleft}{2146}{2018}
\pxDeclarePdfTextCommand{\textquoteright}{2147}{2019}
\pxDeclarePdfTextCommand{\quotesinglbase}{}{201A}
\pxDeclarePdfTextCommand{\texttrademark}{}{2122}
\pxDeclarePdfTextCommand{\L}{}{0141}
\pxDeclarePdfTextCommand{\OE}{}{0152}
\pxDeclarePdfTextComposite{\v}{S}{}{0160}
\pxDeclarePdfTextComposite{\"}{Y}{}{0178}
\pxDeclarePdfTextComposite{\v}{Z}{}{017D}
\pxDeclarePdfTextCommand{\i}{}{0131}
\pxDeclarePdfTextCommand{\l}{}{0142}
\pxDeclarePdfTextCommand{\oe}{}{0153}
\pxDeclarePdfTextComposite{\v}{s}{}{0161}
\pxDeclarePdfTextComposite{\v}{z}{}{017E}
\pxDeclarePdfTextCommand{\texteuro}{}{20AC}
\pxDeclarePdfTextCommand{\textexclamdown}{}{00A1}
\pxDeclarePdfTextCommand{\textcent}{2171}{00A2}
\pxDeclarePdfTextCommand{\textsterling}{2172}{00A3}
\pxDeclarePdfTextCommand{\textcurrency}{}{00A4}
\pxDeclarePdfTextCommand{\textyen}{}{00A5}
\pxDeclarePdfTextCommand{\textbrokenbar}{}{00A6}
\pxDeclarePdfTextCommand{\textsection}{2178}{00A7}
\pxDeclarePdfTextCommand{\textasciidieresis}{212F}{00A8}
\pxDeclarePdfTextCommand{\textcopyright}{}{00A9}
\pxDeclarePdfTextCommand{\textordfeminine}{}{00AA}
\pxDeclarePdfTextCommand{\guillemotleft}{}{00AB}
\pxDeclarePdfTextCommand{\textlogicalnot}{224C}{00AC}
\pxDeclarePdfTextCommand{\textlnot}{224C}{00AC}
\pxDeclarePdfTextCommand{\textregistered}{}{00AE}
\pxDeclarePdfTextCommand{\textasciimacron}{}{00AF}
\pxDeclarePdfTextCommand{\textdegree}{216B}{00B0}
\pxDeclarePdfTextCommand{\textplusminus}{215E}{00B1}
\pxDeclarePdfTextCommand{\texttwosuperior}{}{00B2}
\pxDeclarePdfTextCommand{\textthreesuperior}{}{00B3}
\pxDeclarePdfTextCommand{\textacute}{212D}{00B4}
%\pxDeclarePdfTextCommand{\textmu}{}{00B5}
\pxDeclarePdfTextCommand{\textparagraph}{2279}{00B6}
\pxDeclarePdfTextCommand{\textperiodcentered}{}{00B7}
\pxDeclarePdfTextCommand{\textcedilla}{}{00B8}
\pxDeclarePdfTextCommand{\textonesuperior}{}{00B9}
\pxDeclarePdfTextCommand{\textordmasculine}{}{00BA}
\pxDeclarePdfTextCommand{\guillemotright}{}{00BB}
\pxDeclarePdfTextCommand{\textonequarter}{}{00BC}
\pxDeclarePdfTextCommand{\textonehalf}{}{00BD}
\pxDeclarePdfTextCommand{\textthreequarters}{}{00BE}
\pxDeclarePdfTextCommand{\textquestiondown}{}{00BF}
\pxDeclarePdfTextComposite{\`}{A}{}{00C0}
\pxDeclarePdfTextComposite{\'}{A}{}{00C1}
\pxDeclarePdfTextComposite{\^}{A}{}{00C2}
\pxDeclarePdfTextComposite{\~}{A}{}{00C3}
\pxDeclarePdfTextComposite{\"}{A}{}{00C4}
\pxDeclarePdfTextComposite{\r}{A}{}{00C5}
\pxDeclarePdfTextCommand{\AE}{}{00C6}
\pxDeclarePdfTextComposite{\c}{C}{}{00C7}
\pxDeclarePdfTextComposite{\`}{E}{}{00C8}
\pxDeclarePdfTextComposite{\'}{E}{}{00C9}
\pxDeclarePdfTextComposite{\^}{E}{}{00CA}
\pxDeclarePdfTextComposite{\"}{E}{}{00CB}
\pxDeclarePdfTextComposite{\`}{I}{}{00CC}
\pxDeclarePdfTextComposite{\'}{I}{}{00CD}
\pxDeclarePdfTextComposite{\^}{I}{}{00CE}
\pxDeclarePdfTextComposite{\"}{I}{}{00CF}
\pxDeclarePdfTextCommand{\DH}{}{00D0}
\pxDeclarePdfTextCommand{\DJ}{}{00D0}
\pxDeclarePdfTextComposite{\~}{N}{}{00D1}
\pxDeclarePdfTextComposite{\`}{O}{}{00D2}
\pxDeclarePdfTextComposite{\'}{O}{}{00D3}
\pxDeclarePdfTextComposite{\^}{O}{}{00D4}
\pxDeclarePdfTextComposite{\~}{O}{}{00D5}
\pxDeclarePdfTextComposite{\"}{O}{}{00D6}
\pxDeclarePdfTextCommand{\textmultiply}{215F}{00D7}
\pxDeclarePdfTextCommand{\O}{}{00D8}
\pxDeclarePdfTextComposite{\`}{U}{}{00D9}
\pxDeclarePdfTextComposite{\'}{U}{}{00DA}
\pxDeclarePdfTextComposite{\^}{U}{}{00DB}
\pxDeclarePdfTextComposite{\"}{U}{}{00DC}
\pxDeclarePdfTextComposite{\'}{Y}{}{00DD}
\pxDeclarePdfTextCommand{\TH}{}{00DE}
\pxDeclarePdfTextCommand{\ss}{}{00DF}
\pxDeclarePdfTextComposite{\`}{a}{}{00E0}
\pxDeclarePdfTextComposite{\'}{a}{}{00E1}
\pxDeclarePdfTextComposite{\^}{a}{}{00E2}
\pxDeclarePdfTextComposite{\~}{a}{}{00E3}
\pxDeclarePdfTextComposite{\"}{a}{}{00E4}
\pxDeclarePdfTextComposite{\r}{a}{}{00E5}
\pxDeclarePdfTextCommand{\ae}{}{00E6}
\pxDeclarePdfTextComposite{\c}{c}{}{00E7}
\pxDeclarePdfTextComposite{\`}{e}{}{00E8}
\pxDeclarePdfTextComposite{\'}{e}{}{00E9}
\pxDeclarePdfTextComposite{\^}{e}{}{00EA}
\pxDeclarePdfTextComposite{\"}{e}{}{00EB}
\pxDeclarePdfTextComposite{\`}{i}{}{00EC}
\pxDeclarePdfTextComposite{\`}{\i}{}{00EC}
\pxDeclarePdfTextComposite{\'}{i}{}{00ED}
\pxDeclarePdfTextComposite{\'}{\i}{}{00ED}
\pxDeclarePdfTextComposite{\^}{i}{}{00EE}
\pxDeclarePdfTextComposite{\^}{\i}{}{00EE}
\pxDeclarePdfTextComposite{\"}{i}{}{00EF}
\pxDeclarePdfTextComposite{\"}{\i}{}{00EF}
\pxDeclarePdfTextCommand{\dh}{}{00F0}
\pxDeclarePdfTextComposite{\~}{n}{}{00F1}
\pxDeclarePdfTextComposite{\`}{o}{}{00F2}
\pxDeclarePdfTextComposite{\'}{o}{}{00F3}
\pxDeclarePdfTextComposite{\^}{o}{}{00F4}
\pxDeclarePdfTextComposite{\~}{o}{}{00F5}
\pxDeclarePdfTextComposite{\"}{o}{}{00F6}
\pxDeclarePdfTextCommand{\textdivide}{2160}{00F7}
\pxDeclarePdfTextCommand{\o}{}{00F8}
\pxDeclarePdfTextComposite{\`}{u}{}{00F9}
\pxDeclarePdfTextComposite{\'}{u}{}{00FA}
\pxDeclarePdfTextComposite{\^}{u}{}{00FB}
\pxDeclarePdfTextComposite{\"}{u}{}{00FC}
\pxDeclarePdfTextComposite{\'}{y}{}{00FD}
\pxDeclarePdfTextCommand{\th}{}{00FE}
\pxDeclarePdfTextComposite{\"}{y}{}{00FF}
\pxDeclarePdfTextCommand{\textcelsius}{216E}{2103}
%%

%%[B] Aliases to [A].
%\pxDeclarePdfTextCommand{\copyright}{}{00A9}
\pxDeclarePdfTextCommand{\textflqq}{}{00AB}
\pxDeclarePdfTextCommand{\flqq}{}{00AB}
\pxDeclarePdfTextCommand{\textneg}{224C}{00AC}
\pxDeclarePdfTextCommand{\textpm}{215E}{00B1}
\pxDeclarePdfTextCommand{\textcdot}{}{00B7}
\pxDeclarePdfTextCommand{\textfrqq}{}{00BB}
\pxDeclarePdfTextCommand{\frqq}{}{00BB}
\pxDeclarePdfTextCommand{\texttimes}{215F}{00D7}
\pxDeclarePdfTextCommand{\textdiv}{2160}{00F7}
\pxDeclarePdfTextCommand{\textgrq}{2146}{2018}
\pxDeclarePdfTextCommand{\textglq}{}{201A}
\pxDeclarePdfTextCommand{\textquotesinglbase}{}{201A}
\pxDeclarePdfTextCommand{\textgrqq}{2148}{201C}
\pxDeclarePdfTextCommand{\crqq}{2148}{201C}
\pxDeclarePdfTextCommand{\textglqq}{}{201E}
\pxDeclarePdfTextCommand{\clqq}{}{201E}
\pxDeclarePdfTextCommand{\textquotedblbase}{}{201E}
\pxDeclarePdfTextCommand{\textflq}{}{2039}
\pxDeclarePdfTextCommand{\textfrq}{}{203A}
\pxDeclarePdfTextCommand{\textEuro}{}{20AC}
\pxDeclarePdfTextCommand{\guillemetleft}{}{00AB}
\pxDeclarePdfTextCommand{\guillemetright}{}{00BB}
%%

%%[C] The characters that are included both in JIS X 0213
% and some of the TeX encodings.
% Note: The entries marked with (*) involves non-standard mappings.
\pxDeclarePdfTextCommand{\textbardbl}{2142}{2016}
\pxDeclarePdfTextCommand{\textlangle}{2152}{3008}%(*)2329
\pxDeclarePdfTextCommand{\textrangle}{2153}{3009}%(*)232A
\pxDeclarePdfTextCommand{\textxleq}{2165}{2266}%(*)2264
\pxDeclarePdfTextCommand{\textxgeq}{2166}{2267}%(*)2265
\pxDeclarePdfTextCommand{\textinfty}{2167}{221E}
\pxDeclarePdfTextCommand{\textborn}{217A}{2605}
\pxDeclarePdfTextCommand{\textreferencemark}{2228}{203B}
\pxDeclarePdfTextCommand{\textrightarrow}{222A}{2192}
\pxDeclarePdfTextCommand{\textleftarrow}{222B}{2190}
\pxDeclarePdfTextCommand{\textuparrow}{222C}{2191}
\pxDeclarePdfTextCommand{\textdownarrow}{222D}{2193}
\pxDeclarePdfTextCommand{\textsurd}{2265}{221A}
\pxDeclarePdfTextCommand{\textapprox}{}{2245}
\pxDeclarePdfTextCommand{\textmusicalnote}{2276}{266A}
\pxDeclarePdfTextCommand{\textbigcircle}{227E}{25EF}
\pxDeclarePdfTextCommand{\textopenbullet}{}{25E6}
\pxDeclarePdfTextCommand{\textell}{}{2113}
\pxDeclarePdfTextCommand{\textmho}{}{2127}
\pxDeclarePdfTextCommand{\textAlpha}{2621}{0391}
\pxDeclarePdfTextCommand{\textBeta}{2622}{0392}
\pxDeclarePdfTextCommand{\textGamma}{2623}{0393}
\pxDeclarePdfTextCommand{\textDelta}{2624}{0394}
\pxDeclarePdfTextCommand{\textEpsilon}{2625}{0395}
\pxDeclarePdfTextCommand{\textZeta}{2626}{0396}
\pxDeclarePdfTextCommand{\textEta}{2627}{0397}
\pxDeclarePdfTextCommand{\textTheta}{2628}{0398}
\pxDeclarePdfTextCommand{\textIota}{2629}{0399}
\pxDeclarePdfTextCommand{\textKappa}{262A}{039A}
\pxDeclarePdfTextCommand{\textLambda}{262B}{039B}
\pxDeclarePdfTextCommand{\textMu}{262C}{039C}
\pxDeclarePdfTextCommand{\textNu}{262D}{039D}
\pxDeclarePdfTextCommand{\textXi}{262E}{039E}
\pxDeclarePdfTextCommand{\textOmicron}{262F}{039F}
\pxDeclarePdfTextCommand{\textPi}{2630}{03A0}
\pxDeclarePdfTextCommand{\textRho}{2631}{03A1}
\pxDeclarePdfTextCommand{\textSigma}{2632}{03A3}
\pxDeclarePdfTextCommand{\textTau}{2633}{03A4}
\pxDeclarePdfTextCommand{\textUpsilon}{2634}{03A5}
\pxDeclarePdfTextCommand{\textPhi}{2635}{03A6}
\pxDeclarePdfTextCommand{\textChi}{2636}{03A7}
\pxDeclarePdfTextCommand{\textPsi}{2637}{03A8}
\pxDeclarePdfTextCommand{\textOmega}{2638}{03A9}
\pxDeclarePdfTextCommand{\textohm}{2638}{03A9}%(*)2126
\pxDeclarePdfTextCommand{\textalpha}{2641}{03B1}
\pxDeclarePdfTextCommand{\textbeta}{2642}{03B2}
\pxDeclarePdfTextCommand{\textgamma}{2643}{03B3}
\pxDeclarePdfTextCommand{\textdelta}{2644}{03B4}
\pxDeclarePdfTextCommand{\textepsilon}{2645}{03B5}
\pxDeclarePdfTextCommand{\textzeta}{2646}{03B6}
\pxDeclarePdfTextCommand{\texteta}{2647}{03B7}
\pxDeclarePdfTextCommand{\texttheta}{2648}{03B8}
\pxDeclarePdfTextCommand{\textiota}{2649}{03B9}
\pxDeclarePdfTextCommand{\textkappa}{264A}{03BA}
\pxDeclarePdfTextCommand{\textlambda}{264B}{03BB}
\pxDeclarePdfTextCommand{\textmu}{264C}{03BC}
\pxDeclarePdfTextCommand{\textnu}{264D}{03BD}
\pxDeclarePdfTextCommand{\textxi}{264E}{03BE}
\pxDeclarePdfTextCommand{\textomicron}{264F}{03BF}
\pxDeclarePdfTextCommand{\textpi}{2650}{03C0}
\pxDeclarePdfTextCommand{\textrho}{2651}{03C1}
\pxDeclarePdfTextCommand{\textsigma}{2652}{03C3}
\pxDeclarePdfTextCommand{\texttau}{2653}{03C4}
\pxDeclarePdfTextCommand{\textupsilon}{2654}{03C5}
\pxDeclarePdfTextCommand{\textphi}{2655}{03C6}
\pxDeclarePdfTextCommand{\textchi}{2656}{03C7}
\pxDeclarePdfTextCommand{\textpsi}{2657}{03C8}
\pxDeclarePdfTextCommand{\textomega}{2658}{03C9}
\pxDeclarePdfTextCommand{\textvarsigma}{}{03C2}
\pxDeclarePdfTextCommand{\textfinalsigma}{}{03C2}
\pxDeclarePdfTextCommand{\CYRA}{2721}{0410}
\pxDeclarePdfTextCommand{\CYRB}{2722}{0411}
\pxDeclarePdfTextCommand{\CYRV}{2723}{0412}
\pxDeclarePdfTextCommand{\CYRG}{2724}{0413}
\pxDeclarePdfTextCommand{\CYRD}{2725}{0414}
\pxDeclarePdfTextCommand{\CYRE}{2726}{0415}
\pxDeclarePdfTextCommand{\CYRYO}{2727}{0401}
\pxDeclarePdfTextCommand{\CYRZH}{2728}{0416}
\pxDeclarePdfTextCommand{\CYRZ}{2729}{0417}
\pxDeclarePdfTextCommand{\CYRI}{272A}{0418}
\pxDeclarePdfTextCommand{\CYRISHRT}{272B}{0419}
\pxDeclarePdfTextCommand{\CYRK}{272C}{041A}
\pxDeclarePdfTextCommand{\CYRL}{272D}{041B}
\pxDeclarePdfTextCommand{\CYRM}{272E}{041C}
\pxDeclarePdfTextCommand{\CYRN}{272F}{041D}
\pxDeclarePdfTextCommand{\CYRO}{2730}{041E}
\pxDeclarePdfTextCommand{\CYRP}{2731}{041F}
\pxDeclarePdfTextCommand{\CYRR}{2732}{0420}
\pxDeclarePdfTextCommand{\CYRS}{2733}{0421}
\pxDeclarePdfTextCommand{\CYRT}{2734}{0422}
\pxDeclarePdfTextCommand{\CYRU}{2735}{0423}
\pxDeclarePdfTextCommand{\CYRF}{2736}{0424}
\pxDeclarePdfTextCommand{\CYRH}{2737}{0425}
\pxDeclarePdfTextCommand{\CYRC}{2738}{0426}
\pxDeclarePdfTextCommand{\CYRCH}{2739}{0427}
\pxDeclarePdfTextCommand{\CYRSH}{273A}{0428}
\pxDeclarePdfTextCommand{\CYRSHCH}{273B}{0429}
\pxDeclarePdfTextCommand{\CYRHRDSN}{273C}{042A}
\pxDeclarePdfTextCommand{\CYRERY}{273D}{042B}
\pxDeclarePdfTextCommand{\CYRSFTSN}{273E}{042C}
\pxDeclarePdfTextCommand{\CYREREV}{273F}{042D}
\pxDeclarePdfTextCommand{\CYRYU}{2740}{042E}
\pxDeclarePdfTextCommand{\CYRYA}{2741}{042F}
\pxDeclarePdfTextCommand{\cyra}{2751}{0430}
\pxDeclarePdfTextCommand{\cyrb}{2752}{0431}
\pxDeclarePdfTextCommand{\cyrv}{2753}{0432}
\pxDeclarePdfTextCommand{\cyrg}{2754}{0433}
\pxDeclarePdfTextCommand{\cyrd}{2755}{0434}
\pxDeclarePdfTextCommand{\cyre}{2756}{0435}
\pxDeclarePdfTextCommand{\cyryo}{2757}{0451}
\pxDeclarePdfTextCommand{\cyrzh}{2758}{0436}
\pxDeclarePdfTextCommand{\cyrz}{2759}{0437}
\pxDeclarePdfTextCommand{\cyri}{275A}{0438}
\pxDeclarePdfTextCommand{\cyrishrt}{275B}{0439}
\pxDeclarePdfTextCommand{\cyrk}{275C}{043A}
\pxDeclarePdfTextCommand{\cyrl}{275D}{043B}
\pxDeclarePdfTextCommand{\cyrm}{275E}{043C}
\pxDeclarePdfTextCommand{\cyrn}{275F}{043D}
\pxDeclarePdfTextCommand{\cyro}{2760}{043E}
\pxDeclarePdfTextCommand{\cyrp}{2761}{043F}
\pxDeclarePdfTextCommand{\cyrr}{2762}{0440}
\pxDeclarePdfTextCommand{\cyrs}{2763}{0441}
\pxDeclarePdfTextCommand{\cyrt}{2764}{0442}
\pxDeclarePdfTextCommand{\cyru}{2765}{0443}
\pxDeclarePdfTextCommand{\cyrf}{2766}{0444}
\pxDeclarePdfTextCommand{\cyrh}{2767}{0445}
\pxDeclarePdfTextCommand{\cyrc}{2768}{0446}
\pxDeclarePdfTextCommand{\cyrch}{2769}{0447}
\pxDeclarePdfTextCommand{\cyrsh}{276A}{0448}
\pxDeclarePdfTextCommand{\cyrshch}{276B}{0449}
\pxDeclarePdfTextCommand{\cyrhrdsn}{276C}{044A}
\pxDeclarePdfTextCommand{\cyrery}{276D}{044B}
\pxDeclarePdfTextCommand{\cyrsftsn}{276E}{044C}
\pxDeclarePdfTextCommand{\cyrerev}{276F}{044D}
\pxDeclarePdfTextCommand{\cyryu}{2770}{044E}
\pxDeclarePdfTextCommand{\cyrya}{2771}{044F}
\pxDeclarePdfTextCommand{\textvisiblespace}{}{2423}
\pxDeclarePdfTextComposite{\=}{A}{}{0100}
\pxDeclarePdfTextComposite{\=}{I}{}{012A}
\pxDeclarePdfTextComposite{\=}{U}{}{016A}
\pxDeclarePdfTextComposite{\=}{E}{}{0112}
\pxDeclarePdfTextComposite{\=}{O}{}{014C}
\pxDeclarePdfTextComposite{\=}{a}{}{0101}
\pxDeclarePdfTextComposite{\=}{i}{}{012B}
\pxDeclarePdfTextComposite{\=}{\i}{}{012B}
\pxDeclarePdfTextComposite{\=}{u}{}{016B}
\pxDeclarePdfTextComposite{\=}{e}{}{0113}
\pxDeclarePdfTextComposite{\=}{o}{}{014D}
\pxDeclarePdfTextComposite{\k}{A}{}{0104}
\pxDeclarePdfTextComposite{\v}{L}{}{013D}
\pxDeclarePdfTextComposite{\'}{S}{}{015A}
\pxDeclarePdfTextComposite{\c}{S}{}{015E}
\pxDeclarePdfTextComposite{\v}{T}{}{0164}
\pxDeclarePdfTextComposite{\'}{Z}{}{0179}
\pxDeclarePdfTextComposite{\.}{Z}{}{017B}
\pxDeclarePdfTextComposite{\k}{a}{}{0105}
\pxDeclarePdfTextComposite{\v}{l}{}{013E}
\pxDeclarePdfTextComposite{\'}{s}{}{015B}
\pxDeclarePdfTextComposite{\c}{s}{}{015F}
\pxDeclarePdfTextComposite{\v}{t}{}{0165}
\pxDeclarePdfTextComposite{\'}{z}{}{017A}
\pxDeclarePdfTextComposite{\.}{z}{}{017C}
\pxDeclarePdfTextComposite{\'}{R}{}{0154}
\pxDeclarePdfTextComposite{\u}{A}{}{0102}
\pxDeclarePdfTextComposite{\'}{L}{}{0139}
\pxDeclarePdfTextComposite{\'}{C}{}{0106}
\pxDeclarePdfTextComposite{\v}{C}{}{010C}
\pxDeclarePdfTextComposite{\k}{E}{}{0118}
\pxDeclarePdfTextComposite{\v}{E}{}{011A}
\pxDeclarePdfTextComposite{\v}{D}{}{010E}
\pxDeclarePdfTextComposite{\'}{N}{}{0143}
\pxDeclarePdfTextComposite{\v}{N}{}{0147}
\pxDeclarePdfTextComposite{\H}{O}{}{0150}
\pxDeclarePdfTextComposite{\v}{R}{}{0158}
\pxDeclarePdfTextComposite{\r}{U}{}{016E}
\pxDeclarePdfTextComposite{\H}{U}{}{0170}
\pxDeclarePdfTextComposite{\c}{T}{}{0162}
\pxDeclarePdfTextComposite{\'}{r}{}{0155}
\pxDeclarePdfTextComposite{\u}{a}{}{0103}
\pxDeclarePdfTextComposite{\'}{l}{}{013A}
\pxDeclarePdfTextComposite{\'}{c}{}{0107}
\pxDeclarePdfTextComposite{\v}{c}{}{010D}
\pxDeclarePdfTextComposite{\k}{e}{}{0119}
\pxDeclarePdfTextComposite{\v}{e}{}{011B}
\pxDeclarePdfTextComposite{\v}{d}{}{010F}
\pxDeclarePdfTextCommand{\dj}{}{0111}
\pxDeclarePdfTextComposite{\'}{n}{}{0144}
\pxDeclarePdfTextComposite{\v}{n}{}{0148}
\pxDeclarePdfTextComposite{\H}{o}{}{0151}
\pxDeclarePdfTextComposite{\v}{r}{}{0159}
\pxDeclarePdfTextComposite{\r}{u}{}{016F}
\pxDeclarePdfTextComposite{\H}{u}{}{0171}
\pxDeclarePdfTextComposite{\c}{t}{}{0163}
\pxDeclarePdfTextCommand{\ng}{}{014B}
\pxDeclarePdfTextCommand{\textnumero}{}{2116}
%%

% Give a substitute definition to characters that appear as
% ligatures, since otherwise hyperref leaves some garbage in
% output pdf-strings when such ligatures appear.
\ifpxhy@uptex\else
  \ifpxhy@uniescape\else
    \DeclareTextCommand{\textendash}{PD1}{--}
    \DeclareTextCommand{\textquestiondown}{PD1}{}% empty
    \DeclareTextCommand{\textexclamdown}{PD1}{}% empty
  \fi
\fi

\fi                             %</unicode>
%%%%%%%%%%%%%%%%%%%% done

%--------------------------------------- Enable hyperref unicode
\ifpxhy@hy@unicode

%% check the current meaning
\def\pxhy@tmpa#1{\@backslashchar 000#1}
\ifx\HyPsd@Char\pxhy@tmpa
\PackageInfo\pxhy@pkgname
 {The setup for hyperref 'unicode' is applied.\@gobbletwo}

%% The following code is taken from hyperref.sty.
%%%%BEGIN
  \def\HyPsd@Char#1{%
    \ifnum`#1<128 %
      \@backslashchar 000#1%
    \else
      \ifnum`#1<65536 %
        \expandafter\HyPsd@CharTwoByte\number`#1!%
      \else
        \expandafter\expandafter\expandafter\HyPsd@CharSurrogate
        \intcalcSub{`#1}{65536}!%
      \fi
    \fi
  }%
  \def\HyPsd@CharTwoByte#1!{%
    \expandafter\expandafter\expandafter\HyPsd@CharOctByte
    \IntCalcDiv#1!256!!%
    \expandafter\expandafter\expandafter\HyPsd@CharOctByte
    \IntCalcMod#1!256!!%
  }%
  \def\HyPsd@CharOctByte#1!{%
    \@backslashchar
    \IntCalcDiv#1!64!%
    \intcalcDiv{\IntCalcMod#1!64!}{8}%
    \IntCalcMod#1!8!%
  }%
  \def\HyPsd@CharSurrogate#1!{%
    \@backslashchar 33%
    \IntCalcDiv#1!262144!%
    \expandafter\expandafter\expandafter\HyPsd@CharOctByte
    \intcalcDiv{\IntCalcMod#1!262144!}{1024}!%
    \@backslashchar 33%
    \expandafter\expandafter\expandafter\IntCalcAdd
    \intcalcDiv{\IntCalcMod#1!1024!}{256}!4!%
    \expandafter\expandafter\expandafter\HyPsd@CharOctByte
    \IntCalcMod#1!256!!%
  }%
%%%%END
\fi

\ifpxhy@uptex\else                      %<*pTeX>
  \RequirePackage{bxjatoucs}[]
  \def\HyPsd@Char#1{%
    \ifnum`#1<128 %
      \@backslashchar 000#1%
    \else\ifnum`#1<256 %
      \expandafter\HyPsd@CharTwoByte\number`#1!%
    \else
      \expandafter\HyPsd@CharTwoByte\number\pxhy@to@ucs{`#1}!%
    \fi\fi
  }%
  \def\pxhy@to@ucs#1{"FFFD}
  \ifnum\jis"2121="8140 % sjis
    \let\pxhy@to@ucs\bxjaSjisToUcs
  \else\ifnum\jis"2121="A1A1 % euc
    \let\pxhy@to@ucs\bxjaEucToUcs
  \fi\fi
\fi                                     %</pTeX>

%% disable the verification of bxjscls
\let\jsCheckHyperrefUnicode\@empty

\fi
%--------------------------------------- 'jacommentline'
\ifpxhy@jacommentline

% The 'jacomemntline' feature outputs at the top of the
% hyperref outline file (*.out) a comment line including
% some Japanese characters.

%% \pxhy@jacomment
\let\pxhy@jacomment\@empty
\begingroup
  \@for\pxhy@x:={%
    2433,244E,2555,2521,2524,256B,244F,467C,4B5C,386C,%
    4A38,3B7A,2472,345E,245F,245E,2439%
  }\do{%
    \kansujichar1=\jis"\pxhy@x\relax
    \xdef\pxhy@jacomment{\pxhy@jacomment\kansuji1}%
  }
\endgroup

%% attach a hook
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname ReadBookmarks\endcsname\relax\else
  \g@addto@macro\ReadBookmarks{%
    \if@filesw
      \ifx\@outlinefile\@undefined\else
        \immediate\write\@outlinefile{%
          \@percentchar\pxhy@jacomment.}%
      \fi
    \fi
  }
\fi

\fi
%--------------------------------------- 'disablecmds'
\ifpxhy@disablecmds

%% \pxhy@rensuji
\ifpxhy@etex
  \def\pxhy@rensuji{%
    \pxhy@if@star\pxhy@rensuji@a\pxhy@rensuji@a
  }
  \def\pxhy@rensuji@a{%
    \pxhy@if@opt\@secondoftwo\@firstofone
  }
\else
  \let\pxhy@rensuji\relax % freeze
\fi

%% \pxhy@ifdef@let\CSa\CSb
\def\pxhy@ifdef@let#1#2{%
  \ifx#1\@undefined\else
    \let#1#2%
  \fi
}

%% \pxhy@disable@commands
\def\pxhy@disable@commands{%
  % pTeX primitives
  \let\autospacing\@empty
  \let\autoxspacing\@empty
  \let\inhibitglue\@empty
  \let\noautospacing\@empty
  \let\noautoxspacing\@empty
  % pLaTeX core
  \let\romanencoding\@gobble
  \let\kanjiencoding\@gobble
  \let\romanfamily\@gobble
  \let\kanjifamily\@gobble
  \let\romanseries\@gobble
  \let\kanjiseries\@gobble
  \let\romanshape\@gobble
  \let\kanjishape\@gobble
  \let\useroman\@gobblefour
  \let\usekanji\@gobblefour
  \let\textmc\@firstofone
  \let\textgt\@firstofone
  \let\mcfamily\@empty
  \let\gtfamily\@empty
  \let\userelfont\@empty
  \let\<\@empty
  % plext
  \pxhy@ifdef@let\bou\@firstofone
  \pxhy@ifdef@let\kasen\@firstofone
  \pxhy@ifdef@let\rensuji\pxhy@rensuji
  \pxhy@ifdef@let\prensuji\pxhy@rensuji
  \pxhy@ifdef@let\Rensuji\pxhy@rensuji
  % japanese-otf
  \pxhy@ifdef@let\textmg\@firstofone
  \pxhy@ifdef@let\mgfamily\@empty
  \pxhy@ifdef@let\ltseries\@empty
  \pxhy@ifdef@let\ebseries\@empty
  \pxhy@ifdef@let\propshape\@empty
}

%% register to 'disable' list
% This registration should be of lower priority than others,
% and thus is prepended to pdfstringdefPreHook.
\ltx@GlobalPrependToMacro\pdfstringdefPreHook{\pxhy@disable@commands}

\fi
%--------------------------------------- All done
\endinput
%% EOF
