%%
%% This is file 'pxjahyper.sty'.
%%
%% Copyright (c) 2012-2023 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}[2023/03/01 v1.3]
\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{keyval}\relax
\RequirePackage{ltxcmds}[2011/08/22]% v1.21

%% variables
\newif\ifpxhy@ptex
\newif\ifpxhy@uptex
\newif\ifpxhy@etex
\newif\ifpxhy@etoolbox
\chardef\pxhy@hook@system=0
\newif\ifpxhy@tounicode
\newif\ifpxhy@uniescape
\newif\ifpxhy@bigcode
\let\pxhy@bigcode@given\relax
\newif\ifpxhy@papersize
\newif\ifpxhy@charcmds
\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
\newif\ifpxhy@Uchar@avail
\newif\ifpxhy@ucs@avail
\let\pxhy@jsclasses@name\relax
\newif\ifpxhy@jlreq@cls
\newif\ifpxhy@fallback@geta
\newif\ifpxhy@extjis@map
\newif\ifpxhy@extjis@use
\newif\ifpxhy@ajhankaku@chars

%%<*> \pxjahypersetup{<key>=<value>,...}
\newcommand*\pxjahypersetup{%
  \setkeys{\pxhy@pkgname}%
}
%% \pxhy@handle@key{<key>}{<value>}{<name>}
\def\pxhy@handle@key#1#2#3{%
  \expandafter\let\expandafter\pxhy@tmpa\csname pxhy@#3\endcsname
  \ifx\pxhy@tmpa\relax
    \PackageError\pxhy@pkgname
     {Invalid value for key '#1':\MessageBreak\@spaces#2}%
     {\@eha}%
  \else \pxhy@tmpa
  \fi
}

%--------------------------------------- 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
}
\DeclareOption{resetdvidriver}{%
  \let\pxhy@driver\@undefined
}
\DeclareOption{autodvidriver}{%
  \let\pxhy@driver\@undefined
}
\DeclareOption{auto}{% DEPRECATED
  \let\pxhy@driver\@undefined
}
%% operation modes
\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
}
\DeclareOption{charcmds}{%
  \pxhy@charcmdstrue
}
\DeclareOption{nocharcmds}{%
  \pxhy@charcmdsfalse
}
\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{fallback-geta}{%
  \pxjahypersetup{fallback=geta}%
}
\DeclareOption{fallback-delete}{%
  \pxjahypersetup{fallback=delete}%
}
\DeclareOption{force-unicode}{%
  \let\pxhy@force@unicode=t
}
\DeclareOption{disable-Ux}{% for debug
  \let\pxhy@disable@Ux=t
}
%% key-value options
\DeclareOption*{%
  \expandafter\pxjahypersetup\expandafter{\CurrentOption}%
}
% 'fallback=geta|delete'
\pxhy@fallback@getatrue
\define@key{\pxhy@pkgname}{fallback}{%
  \pxhy@handle@key{fallback}{#1}{kv@fallback@@#1}%
}
\let\pxhy@kv@fallback@@geta\pxhy@fallback@getatrue
\let\pxhy@kv@fallback@@delete\pxhy@fallback@getafalse
% 'extjis=<bool>'
\pxhy@extjis@usetrue
\define@key{\pxhy@pkgname}{extjis}[true]{%
  \pxhy@handle@key{extjis}{#1}{extjis@use#1}%
}
% 'ajhankaku-chars=<bool>'
\define@key{\pxhy@pkgname}{ajhankaku-chars}[true]{%
  \pxhy@handle@key{ajhankaku-chars}{#1}{ajhankaku@chars#1}%
}
%% dispatch
\ExecuteOptions{%
  resetdvidriver,tounicode,papersize,charcmds,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
  \ifnum\pxhy@driver=\pxhy@driver@none \ifx\Hy@driver\@undefined\else
    \PackageWarningNoLine\pxhy@pkgname
     {Unknown hyperref driver: \Hy@driver}
  \fi\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\ucs{%
    \pxhy@check\ptexversion{\pxhy@uptextrue}
    \pxhy@check\kchardef{\pxhy@uptextrue}
    \ifpxhy@uptex\else % upTeX v<0.10
      \pxhy@error{This upTeX engine is too old}
       {\pxhy@eh@fatal}
      \endinput
    \fi % only upTeX in Unicode is seen as upTeX
    \ifnum\ucs"3000="3000 \else \pxhy@uptexfalse \fi
  }
}
\ifpxhy@ptex\else
  \pxhy@error{Unknown engine used}%
   {\pxhy@eh@fatal}
  \expandafter\endinput
\fi

%% pxhy@Uchar@avail switch
\pxhy@check\Uchar{\pxhy@Uchar@availtrue}
%% pxhy@ucs@avail switch
\pxhy@check\ucs{\pxhy@ucs@availtrue}

%% pxhy@extjis@map switch
% Note that 'tounicode' is necessary.
\ifpxhy@etex \ifpxhy@uptex\else \ifpxhy@tounicode
  \pxhy@extjis@maptrue
\fi\fi\fi

%% Check the document class.
% jlreq
\ifpxhy@etex
  \ifx\jlreqsetup\@undefined\else \pxhy@jlreq@clstrue \fi
\fi
% jsclasses
\@ifclassloaded{jsarticle}{\def\pxhy@jsclasses@name{jsarticle}}{}
\@ifclassloaded{jsbook}{\def\pxhy@jsclasses@name{jsbook}}{}
\ifx\bxjs@clsname\@undefined\else \let\pxhy@jsclasses@name\relax \fi
\ifx\jsc@clsname\@undefined\else \let\pxhy@jsclasses@name\jsc@clsname \fi

%% Check for the new hook system.
\@ifl@t@r\fmtversion{2021/11/15}{%
  \chardef\pxhy@hook@system=2
}{\@ifl@t@r\fmtversion{2020/02/02}{%
  \chardef\pxhy@hook@system=1
}{}}

%% adjustment
% 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@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@
%  \PackageWarningNoLine\pxhy@pkgname
%   {The support for the hyperref 'unicode' mode\MessageBreak
%    on the pTeX engine is currently experimental}%
\fi
\ifpxhy@hy@unicode
  \pxhy@uniescapefalse
  %\pxhy@otfutftrue
\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

%% in nodvidriver mode
\ifnum\pxhy@driver=\pxhy@driver@none
  \pxhy@papersizefalse
  \pxhy@charcmdsfalse
\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@hook@system = \the\pxhy@hook@system^^J%
pxhy@tounicode = \ifpxhy@tounicode true\else false\fi^^J%
pxhy@uniescape = \ifpxhy@uniescape true\else false\fi^^J%
pxhy@bigcode = \ifpxhy@bigcode true\else false\fi^^J%
pxhy@papersize = \ifpxhy@papersize true\else false\fi^^J%
pxhy@charcmds = \ifpxhy@charcmds true\else false\fi^^J%
pxhy@driver = \the\pxhy@driver^^J%
ifpxhy@hy@unicode = \ifpxhy@hy@unicode true\else false\fi^^J%
pxhy@jacommentline = \ifpxhy@jacommentline true\else false\fi^^J%
pxhy@disablecmds = \ifpxhy@disablecmds true\else false\fi^^J%
pxhy@otfutf = \ifpxhy@otfutf true\else false\fi^^J%
pxhy@otfcid = \ifpxhy@otfcid true\else false\fi^^J%
pxhy@otfmacros = \ifpxhy@otfmacros true\else false\fi^^J%
pxhy@fallback@geta = \ifpxhy@fallback@geta 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>}
\ifnum\pxhy@hook@system>0
  \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{#1}%
    \kansujichar\@ne=#1\relax
    \xdef\pxhy@jchar{\kansuji\@ne}%
  \endgroup
}

%% \pxhy@let@jchar@jc\CS{<jis-code>}
\def\pxhy@let@jchar@jc#1#2{%
  \pxhy@get@jchar{\jis"#2}%
  \let#1\pxhy@jchar
}

%% \pxhy@forcecjktoken{<code>}
\ifpxhy@uptex
  \ifx\forcecjktoken\@undefined
    \def\pxhy@forcecjktoken#1{\kcatcode#1=18 }
  \else \def\pxhy@forcecjktoken#1{\forcecjktoken}
  \fi
\else
  \def\pxhy@forcecjktoken#1{\relax}
\fi

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

%% \pxhy@print@geta
\def\pxhy@print@geta{%
  \ifpxhy@fallback@geta \pxhy@geta \fi
}

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

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

%% \pxhy@csletcs{<csname1>}{<csname2>}
\def\pxhy@csletcs#1#2{%
  \expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname
}

%% \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}}

%% \pxhy@xdetokenize{<text>}
\let\pxhy@xdetokenize\detokenize
\pxhy@check\expanded{%
  \def\pxhy@xdetokenize#1{\detokenize\expandafter{\expanded{#1}}}%
}

\fi
%--------------------------------------- Load bxjatoucs

%% \pxhy@bxjatoucs@failure
% Holds the reason message if bxjatoucs is unavailable;
% otherwise equals to \relax.
\@onlypreamble\pxhy@bxjatoucs@failure
\let\pxhy@bxjatoucs@failure\relax

%% \pxhy@try@load@bxjatoucs
% Tries to load bxjatoucs. If that fails, then it sets the reason
% message to \pxhy@bxjatoucs@failure.
\@onlypreamble\pxhy@try@load@bxjatoucs
\def\pxhy@try@load@bxjatoucs{%
  \global\let\pxhy@try@load@bxjatoucs\relax
  \ifpxhy@etoolbox
    % load bxjatoucs in "check mode"
    \IfFileExists{bxjatoucs.sty}{%
      \let\bxjatoucsCheckAvail=t
      \RequirePackage{bxjatoucs}[]
      \undef\bxjatoucsCheckAvail
    }{}
    % and judge availability
    \ifundef\bxjaCidToUcs{%
      \def\pxhy@bxjatoucs@failure{%
        package 'bxjatoucs' is unavailable%
      }%
    }{}
  \else\ifpxhy@etex
    \def\pxhy@bxjatoucs@failure{%
      package 'etoolbox' is unavailable%
    }
  \else
    \def\pxhy@bxjatoucs@failure{%
      e-TeX extension is unavailable%
    }
  \fi\fi
}

\@tempswafalse
\ifpxhy@uptex\else\ifpxhy@hy@unicode
  \pxhy@try@load@bxjatoucs
  \ifx\pxhy@bxjatoucs@failure\relax\else
    \@tempswatrue
  \fi
\fi\fi
\if@tempswa
  \PackageError\pxhy@pkgname
   {The hyperref 'unicode' mode is not supported\MessageBreak
    because \pxhy@bxjatoucs@failure}%
   {\pxhy@eh@fatal}%
  \expandafter\endinput
\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' lengths.) 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
          \ifdim\stockwidth>\z@ \ifdim\stockheight>\z@
            \paperwidth=\stockwidth
            \paperheight=\stockheight
          \fi\fi
        }%
        \@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
        \ifdim\paperwidth>\z@ \ifdim\paperheight>\z@
          \edef\pxhy@tmpa{%
            \noexpand\pxhy@begin@dvi@hook{%
              \special{papersize=\the\paperwidth,\the\paperheight}}%
          }\pxhy@tmpa
        \fi\fi
      \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@Uchar@avail           %<*Uchar>
  \ifpxhy@uptex

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

  \else\ifpxhy@ucs@avail

    %% \pxhy@Ux
    \def\pxhy@Ux{\pxhy@uchex}
    \pxhy@utfXVIfalse
    \def\pxhy@uchex@out#1{%
      \expandafter\pxhy@uchex@out@a\ucs"#1\pxhy@mk{#1}%
    }
    \chardef\pxhy@max@asc="7F
    \def\pxhy@uchex@out@a#1\pxhy@mk#2{%
      \ifnum#1<\z@
        \ifnum"#2>\pxhy@max@asc
          \ifpxhy@extjis@use
            \expandafter\pxhy@uchex@out@b\csname
                pxhy@uc/\number"#2\endcsname{#2}%
          \else \pxhy@uchex@out@b\relax{#2}%
          \fi
        \else \Uchar"#2
        \fi
      \else \Uchar#1
      \fi
    }
    \def\pxhy@uchex@out@b#1#2{%
      \ifx#1\relax
        \@nameuse{U+#2}%
        \pxhy@print@geta
      \else #1%
      \fi
    }

  \fi\fi
\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--

\fi\fi\fi                       %</>

\AtEndOfPackage{%
\ifx\pxhy@posthook\@undefined\else
  \bxDebug{add to \string\pdfstringdefPostHook}%
  % 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
}

\ifpxhy@uniescape               %<*uniescape>

  \let\pxhy@posthook\@undefined
  %% \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>

%% 'disable-Ux' (for debug)
\ifx t\pxhy@disable@Ux
  \let\pxhy@Ux\@undefined
  \let\pxhy@posthook\@undefined
\fi

%% 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

%% \pxhy@let@jchar@uc\CS{<num>}
\ifx\pxhy@Ux\@undefined
  \def\pxhy@let@jchar@uc#1#2{%
    \let#1\noindent % issue a warning
  }
\else
  \def\pxhy@let@jchar@uc#1#2{%
    \def#1{\pxhy@Ux{#2}}%
  }
\fi

%--------------------------------------- Fix for high-byte protection
\ifpxhy@etex
\begingroup
% Check for high-byte protection.
\catcode"EF=\active \catcode`\^=7
\global\let\pxhy@std@EF=^^ef
\def\pxhy@next#1 #2\pxhy@end{%
  \@tempswafalse
  \def\pxhy@tmpa{#1}\edef\pxhy@tmpb{\string\protected}%
  \ifx\pxhy@tmpa\pxhy@tmpb \@tempswatrue \fi
}\expandafter\pxhy@next\meaning\pxhy@std@EF. \pxhy@end
% Add a hook if protected.
\if@tempswa

  %% \pxhy@unprotect@high@bytes
  \let\pxhy@unprotect@high@bytes\@empty
  \def\pxhy@next#1#2{%
    \expandafter\gdef\expandafter#1\expandafter{#2}%
    \edef\pxhy@unprotect@high@bytes{%
      \unexpanded\expandafter{\pxhy@unprotect@high@bytes}%
      \unexpanded{\let#2#1}}%
    \advance\@tempcnta\@ne
  }
  \@tempcnta="C2
  \@whilenum{\@tempcnta<"F5}\do{%
    \lccode"EF=\@tempcnta
    \lowercase{\expandafter\pxhy@next\csname
        pxhy@uhb/\string^^ef\endcsname^^ef}%
  }
  \xdef\pxhy@unprotect@high@bytes{%
    \unexpanded{\ifx^^ef\pxhy@std@EF}%
      \unexpanded\expandafter{\pxhy@unprotect@high@bytes}%
    \unexpanded{\fi}%
  }
  \ltx@GlobalPrependToMacro\pdfstringdefPreHook{\pxhy@unprotect@high@bytes}

\fi
\endgroup
\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@print@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

%% packages
\pxhy@try@load@bxjatoucs

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

%% \pxhy@CID{<cid>}
\def\pxhy@CID#1{%
  \expandafter\expandafter\expandafter\pxhy@cid@aux
      \bxjaCidToUcsHex{#1}\pxhy@mk{\pxhy@xdetokenize{#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@print@geta
  }
\else
\def\pxhy@cid@aux#1\pxhy@mk#2{%
  \ifnum"#1>\z@
    \pxhy@Ux{#1}%
  \else
    \@nameuse{CID+#2}%
    \pxhy@print@geta
  \fi
}
\fi

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

%% \pxhy@dispatch@otfmacros
\@onlypreamble\pxhy@dispatch@otfmacros
\def\pxhy@dispatch@otfmacros{%
  \global\let\pxhy@dispatch@otfmacros\relax
  \ifx\pxhy@bxjatoucs@failure\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
%--------------------------------------- Extended JIS mapping
\ifpxhy@extjis@map             %<*extjis-map>
\begingroup

\def\pxhy@next#1#2#3#4{%
  \@tempcnta"#1\relax\@tempcntb#3\relax
  \chardef\pxhy@tmpa\numexpr#4+1\relax
  \@whilenum{\@tempcntb<\pxhy@tmpa}\do{%
    \expandafter\xdef\csname pxhy@uc/\the\@tempcnta\endcsname{%
      \unexpanded{#2}\the\@tempcntb}%
    \advance\@tempcnta\@ne \advance\@tempcntb\@ne}%
}

%% add special mapping
\ifnum \jis"2121="8140 % sjis
  \pxhy@next{2460}{\207\10}{0}{7}
  \pxhy@next{2468}{\207\11}{0}{7}
  \pxhy@next{2470}{\207\12}{0}{3}
  \pxhy@next{2160}{\207\12}{4}{7}
  \pxhy@next{2164}{\207\13}{0}{5}
  \pxhy@next{3349}{\207\13}{7}{7}
  \pxhy@next{3314}{\207\14}{0}{0}
  \pxhy@next{3322}{\207\14}{1}{1}
  \pxhy@next{334D}{\207\14}{2}{2}
  \pxhy@next{3318}{\207\14}{3}{3}
  \pxhy@next{3327}{\207\14}{4}{4}
  \pxhy@next{3303}{\207\14}{5}{5}
  \pxhy@next{3336}{\207\14}{6}{6}
  \pxhy@next{3351}{\207\14}{7}{7}
  \pxhy@next{3357}{\207\15}{0}{0}
  \pxhy@next{330D}{\207\15}{1}{1}
  \pxhy@next{3326}{\207\15}{2}{2}
  \pxhy@next{3323}{\207\15}{3}{3}
  \pxhy@next{332B}{\207\15}{4}{4}
  \pxhy@next{334A}{\207\15}{5}{5}
  \pxhy@next{333B}{\207\15}{6}{6}
  \pxhy@next{339C}{\207\15}{7}{7}
  \pxhy@next{339D}{\207\16}{0}{1}
  \pxhy@next{338E}{\207\16}{2}{3}
  \pxhy@next{33C4}{\207\16}{4}{4}
  \pxhy@next{33A1}{\207\16}{5}{5}
  \pxhy@next{337B}{\207\17}{6}{6}
  \pxhy@next{301D}{\207\20}{0}{0}
  \pxhy@next{301F}{\207\20}{1}{1}
  \pxhy@next{2116}{\207\20}{2}{2}
  \pxhy@next{33CD}{\207\20}{3}{3}
  \pxhy@next{2121}{\207\20}{4}{4}
  \pxhy@next{32A4}{\207\20}{5}{7}
  \pxhy@next{32A7}{\207\21}{0}{1}
  \pxhy@next{3231}{\207\21}{2}{3}
  \pxhy@next{3239}{\207\21}{4}{4}
  \pxhy@next{337E}{\207\21}{5}{5}
  \pxhy@next{337D}{\207\21}{6}{6}
  \pxhy@next{337C}{\207\21}{7}{7}
  \pxhy@next{222E}{\207\22}{3}{3}
  \pxhy@next{2211}{\207\22}{4}{4}
  \pxhy@next{221F}{\207\23}{0}{0}
  \pxhy@next{22BF}{\207\23}{1}{1}
  \pxhy@next{FF61}{\24}{1}{7}
  \pxhy@next{FF68}{\25}{0}{7}
  \pxhy@next{FF70}{\26}{0}{7}
  \pxhy@next{FF78}{\27}{0}{7}
  \pxhy@next{FF80}{\30}{0}{7}
  \pxhy@next{FF88}{\31}{0}{7}
  \pxhy@next{FF90}{\32}{0}{7}
  \pxhy@next{FF98}{\33}{0}{7}
\else\ifnum\jis"2121="A1A1 % euc
  \pxhy@next{FF61}{\216\24}{1}{7}
  \pxhy@next{FF68}{\216\25}{0}{7}
  \pxhy@next{FF70}{\216\26}{0}{7}
  \pxhy@next{FF78}{\216\27}{0}{7}
  \pxhy@next{FF80}{\216\30}{0}{7}
  \pxhy@next{FF88}{\216\31}{0}{7}
  \pxhy@next{FF90}{\216\32}{0}{7}
  \pxhy@next{FF98}{\216\33}{0}{7}
\fi\fi

%% \pxhy@hkcdot
\global\pxhy@csletcs{pxhy@hkcdot}{pxhy@uc/\number"FF65}

\endgroup
\fi                             %</extjis-map>
%--------------------------------------- Redefine text commands for PD1
\ifpxhy@charcmds                %<*charcmds>

%% \pxhy@cc@jis@only
\chardef\pxhy@cc@jis@only=0
%% \pxhy@pdfenc
\edef\pxhy@pdfenc{%
  \ifpxhy@hy@unicode PU\else PD1\fi
}

%%<+> \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}}%
}

%% \pxhy@revoke@pdf@tc\CS
\@onlypreamble\pxhy@revoke@pdf@tc
\def\pxhy@revoke@pdf@tc#1{%
  \expandafter\let\csname\pxhy@pdfenc\string#1\endcsname\@undefined
  % if current \CS defaults to PD1/PU, hedge to '?'.
  \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{%
  \edef\pxhy@next{{#1}{\ifx\pxhy@mt#2\pxhy@mt FFFD\else#2\fi}}%
  \expandafter\pxhy@get@body\pxhy@next
  \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\ifpxhy@hy@unicode         %<*unicode>
  \def\pxhy@get@body#1#2{%
    \def\pxhy@body{\unichar{"#2}}%
  }%
\else\ifpxhy@uniescape          %<*uniescape>
    \def\pxhy@get@body#1#2{%
      \ifx\pxhy@mt#1\pxhy@mt
        \def\pxhy@body{\0x#2}%
      \else
        \pxhy@get@jchar{\jis"#1}%
        \let\pxhy@body\pxhy@jchar
      \fi
    }%
\else                           %<*!>
  \chardef\pxhy@cc@jis@only=1
    \def\pxhy@get@body#1#2{%
      \ifx\pxhy@mt#1\pxhy@mt
        \let\pxhy@body\@undefined
      \else
        \pxhy@get@jchar{\jis"#1}%
        \let\pxhy@body\pxhy@jchar
      \fi
    }%
\fi\fi\fi                       %</>

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

% The PU encoding has already done the job.
% I supplement some definitions.
\def\pxhy@next#1#2{%
  \expandafter\ifx\csname PU\string#1\endcsname\relax
    \DeclareTextCommand{#1}{PU}{#2}\fi}
\pxhy@next{\guillemetleft}{\80\253}%00AB
\pxhy@next{\guillemetright}{\80\273}%00BB
\pxhy@next{\textborn}{\9046\005}%2605
\pxhy@next{\textfinalsigma}{\83\302}%03C2
\pxhy@next{\textxgeq}{\9042\145}%2265
\pxhy@next{\textxleq}{\9042\144}%2264

\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}
\DeclareTextCommand{\textasteriskcentered}{PD1}{*}
\DeclareTextCommand{\textanoteleia}{PD1}{\textperiodcentered}
\DeclareTextCommand{\texterotimatiko}{PD1}{;}

%% 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{\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}{216F}{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{\textflqq}{}{00AB}
\pxDeclarePdfTextCommand{\textneg}{224C}{00AC}
\pxDeclarePdfTextCommand{\textpm}{215E}{00B1}
\pxDeclarePdfTextCommand{\textcdot}{}{00B7}
\pxDeclarePdfTextCommand{\textfrqq}{}{00BB}
\pxDeclarePdfTextCommand{\texttimes}{215F}{00D7}
\pxDeclarePdfTextCommand{\textdiv}{2160}{00F7}
\pxDeclarePdfTextCommand{\textgrq}{2146}{2018}
\pxDeclarePdfTextCommand{\textglq}{}{201A}
\pxDeclarePdfTextCommand{\textgrqq}{2148}{201C}
\pxDeclarePdfTextCommand{\textglqq}{}{201E}
\pxDeclarePdfTextCommand{\textflq}{}{2039}
\pxDeclarePdfTextCommand{\textfrq}{}{203A}
\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}
\pxDeclarePdfTextComposite{\"}{\CYRE}{2727}{0401}
\pxDeclarePdfTextCommand{\CYRZH}{2728}{0416}
\pxDeclarePdfTextCommand{\CYRZ}{2729}{0417}
\pxDeclarePdfTextCommand{\CYRI}{272A}{0418}
\pxDeclarePdfTextCommand{\CYRISHRT}{272B}{0419}
\pxDeclarePdfTextComposite{\U}{\CYRI}{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}
\pxDeclarePdfTextComposite{\"}{\cyre}{2757}{0451}
\pxDeclarePdfTextCommand{\cyrzh}{2758}{0436}
\pxDeclarePdfTextCommand{\cyrz}{2759}{0437}
\pxDeclarePdfTextCommand{\cyri}{275A}{0438}
\pxDeclarePdfTextCommand{\cyrishrt}{275B}{0439}
\pxDeclarePdfTextComposite{\U}{\cyri}{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.
\ifnum\pxhy@cc@jis@only>\z@
    \DeclareTextCommand{\textendash}{PD1}{--}
    \DeclareTextCommand{\textquestiondown}{PD1}{}% empty
    \DeclareTextCommand{\textexclamdown}{PD1}{}% empty
\fi
\ifnum\pxhy@cc@jis@only>\z@
  \ifx\pxhy@hkcdot\@undefined\else
    \DeclareTextCommand{\textperiodcentered}{PD1}{\pxhy@hkcdot}
  \fi
\fi

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

  %% \pxhy@disable@tc@commands
  \def\pxhy@disable@tc@commands{%
    \let\yen\textyen
    \let\copyright\textcopyright
    \let\flqq\textflqq
    \let\frqq\textfrqq
    \let\textquotesinglbase\quotesinglbase
    \let\crqq\textglqq
    \let\clqq\textgrqq
    \let\textquotedblbase\quotedblbase
    \let\textEuro\texteuro
  }
  %% register to 'disable' list
  \ltx@GlobalPrependToMacro\pdfstringdefPreHook{\pxhy@disable@tc@commands}

\else                           %<*!textcmd>

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

\fi                             %</textcmd>
%--------------------------------------- Enable hyperref unicode
\ifpxhy@hy@unicode

%% load the submodule
\input{pxjahyper-uni.def}
\ifx t\pxHyperrefUnicodePatched
  \PackageInfo\pxhy@pkgname
   {The setup for hyperref 'unicode' is applied.\@gobbletwo}
\else
  \PackageInfo\pxhy@pkgname
   {The setup for hyperref 'unicode' is NOT applied!\MessageBreak
    The package might not work properly.\@gobbletwo}
\fi

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

% The 'jacommentline' 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
  \let\disinhibitglue\@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}

%% additions for jsclasses
\ifx\pxhy@jsclasses@name\relax\else
  \g@addto@macro\pxhy@disable@commands{%
    \let\HUGE\@empty
    \pxhy@ifdef@let\maybeblue\@empty
  }
\fi

%% additions for jlreq
\ifpxhy@jlreq@cls
  % characters
  \pxhy@let@jchar@jc\pxhy@C@ZWSP{2121}
  \pxhy@let@jchar@jc\pxhy@C@ZWQM{2129}
  \pxhy@let@jchar@jc\pxhy@C@ZWEM{212A}
  %% \pxhy@P@tatechuyoko*{<text>}
  \def\pxhy@P@tatechuyoko{\pxhy@if@star\@firstofone\@firstofone}
  %% \pxhy@P@jaspace{<name>}
  \def\pxhy@P@jaspace#1{\@nameuse{jaspace(arg=#1)}}
  \@namedef{jaspace(arg=zenkaku)}{\pxhy@C@ZWSP}
  \@namedef{jaspace(arg=nibu)}{ }
  \@namedef{jaspace(arg=shibu)}{}
  % addition
  \def\pxhy@next#1{%
    \let\expandafter\noexpand\csname#1\endcsname\noexpand#1}
  \edef\pxhy@disable@commands{%
    \unexpanded\expandafter{\pxhy@disable@commands}%
    \pxhy@next\pxhy@C@ZWSP
    \pxhy@next\pxhy@C@ZWQM
    \pxhy@next\pxhy@C@ZWEM
    \unexpanded{%
      \let\jafontsize\@gobbletwo
      \let\jaspace\pxhy@P@jaspace
      \let\tatechuyoko\pxhy@P@tatechuyoko
      \let\jidori\@secondoftwo
      \let\akigumi\@secondoftwo}%
  }
\fi

%% additions for ascmac (experimental)
\@onlypreamble\pxhy@dispatch@dc@ascmac
\def\pxhy@dispatch@dc@ascmac{%
  \pxhy@let@jchar@jc\pxhy@P@yen{216F}
  \pxhy@let@jchar@uc\pxhy@P@return{23CE}
  \g@addto@macro\pxhy@disable@commands{%
    \let\keytop\@firstofone
    \let\yen\pxhy@P@yen
    \let\return\pxhy@P@return
    \let\Return\pxhy@P@return
  }%
}
\pxhy@hook@after@package{ascmac}{\pxhy@dispatch@dc@ascmac}

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