
pax.sty
나는 XeLaTeX에 적응하려고 노력할 것이며 .pax
파일의 URL이 16진수 라인으로 인코딩된다는 것을 발견했습니다.
\[{annot}{1}{Link}{56.693 693.9 156.107 707.7}{URI}{
URI={\<6D61696C746F3A68656C6C6F406578616D706C652E636F6D\>},
Border={[0 0 0]},
}\\
디코딩된 URI는 다음과 같습니다 (에서 볼 수 있음 ).mailto:[email protected]
xxd -r -p
XeLaTeX에서 16진수 라인을 어떻게 디코딩할 수 있나요(16진수를 ASCII로)?
MWE:
\documentclass{article}
\newcommand{\hextotext}[1]{#1} % ???
\begin{document}
\hextotext{6D61696C746F3A68656C6C6F406578616D706C652E636F6D}
\end{document}
답변1
\str_set_convert:Nnnn
(가정)에서 utf8/hex
다음으로 변환하는 데 사용할 수 있습니다 utf8
.
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\str_new:N \l__ivanov_tmpa_str
\NewDocumentCommand \hextotext { o m }
{
\str_set_convert:Nxnn \l__ivanov_tmpa_str {#2}
{ utf8/hex } { utf8 }
\IfValueTF{#1}
{ \str_set_eq:NN #1 \l__ivanov_tmpa_str }
{ \str_use:N \l__ivanov_tmpa_str }
}
\cs_generate_variant:Nn \str_set_convert:Nnnn { Nx }
\ExplSyntaxOff
\begin{document}
\hextotext{6D61696C746F3A68656C6C6F406578616D706C652E636F6D}
\hextotext[\tmp]{6D61696C746F3A68656C6C6F406578616D706C652E636F6D}
\texttt{\meaning\tmp}
\end{document}
이것은 다음을 인쇄합니다:
답변2
특별한 경우 "hex to아스키" (귀하의 질문에 명시된 대로) 예를 들어 전체 시퀀스를 소문자로 지정할 수 있으며 항상 이 시퀀스의 두 연속 문자 앞에 삽입할 수 있으며 예를 들어 -표기법 의 해당 문자 시퀀스로 ^^
해석되는 내용이 있습니다 .\scantokens
^^
\documentclass{article}
\begingroup
\makeatletter
\catcode`\^^A=14\relax
\catcode`\%=12\relax
\@firstofone{^^A
\endgroup
\newcommand\hextotext[2]{^^A
\@ifdefinable#1{^^A
\lowercase{^^A
\scantokens\expandafter{^^A
\expandafter\newcommand\expandafter#1\expandafter{^^A
\romannumeral\expandafter\hextotextloop\expandafter{\expandafter}\detokenize{#2}\relax\relax
}%^^A
}^^A
}^^A
}^^A
}^^A
}%
\begingroup
\makeatletter
\catcode`\^=12\relax
\@firstofone{%
\endgroup
\newcommand*\hextotextloop[3]{%
\ifx\relax#2\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
{\z@#1}{\hextotextloop{#1^^#2#3}}%
}%
}%
\begin{document}
% 6D61696C746F3A68656C6C6F406578616D706C652E636F6D
^^6d^^61^^69^^6c^^74^^6f^^3a^^68^^65^^6c^^6c^^6f^^40^^65^^78^^61^^6d^^70^^6c^^65^^2e^^63^^6f^^6d
\hextotext{\MyCommand}{6D61696C746F3A68656C6C6F406578616D706C652E636F6D}
\begingroup
\ttfamily
\string\MyCommand: \meaning\MyCommand
\endgroup
\MyCommand
\end{document}
그러나 이것은 단지 놀기 위한 것입니다.
실제 시나리오에서 나는 사용할 것입니다Phelype Oleinik의 답변에서 제공되는 내용입니다.여기에는 utf8/hex를 utf8로 변환하는 내용이 포함되어 있으며 ASCII(내 답변에서 다루는 내용)는 utf8의 하위 집합입니다.