<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">% \iffalse meta-comment
% !TEX program  = XeLaTeX
%&lt;*internal&gt;
\iffalse
%&lt;/internal&gt;
%&lt;*readme&gt;
zhnumber
========

The `zhnumber` package provides commands to typeset Chinese representations of
numbers. The main difference between this package and `CJKnumb` is that commands
provided by this package is expandable in the proper way. So, it seems that
zhnumber is a good alternative to `CJKnumb` package.

Basic Usage
-----------
The package provides the following macros:

    \zhnumber{&lt;number&gt;}

Convert `&lt;number&gt;` to a full Chinese representation.

    \zhnum{&lt;counter&gt;}

Similar to `\arabic{&lt;counter&gt;}`, but representation of `&lt;counter&gt;`
as Chinese numerals.

    \zhdigits{&lt;number&gt;}
    \zhdigits*{&lt;number&gt;}

Handle `&lt;number&gt;` as a string of digits and convert each of them into the
corresponding Chinese digit. The starred version uses the Chinese circle glyph
for digit zero; the unstarred version uses the traditional glyph.

You can read the package manual (in Chinese) for more detailed explanations.

Contributing
------------

This package is a part of the [ctex-kit](https://github.com/CTeX-org/ctex-kit) project.

Issues and pull requests are welcome.

Copyright and Licence
---------------------

    Copyright (C) 2012, 2014-2020, 2022 by Qing Lee &lt;sobenlee@gmail.com&gt;
    ----------------------------------------------------------------------

    This work may be distributed and/or modified under the
    conditions of the LaTeX Project Public License, either
    version 1.3c of this license or (at your option) any later
    version. This version of this license is in
       http://www.latex-project.org/lppl/lppl-1-3c.txt
    and the latest version of this license is in
       http://www.latex-project.org/lppl.txt
    and version 1.3 or later is part of all distributions of
    LaTeX version 2005/12/01 or later.

    This work has the LPPL maintenance status "maintained".

    The Current Maintainer of this work is Qing Lee.

    This package consists of the file  zhnumber.dtx,
                 and the derived files zhnumber.pdf,
                                       zhnumber.sty,
                                       zhnumber-utf8.cfg,
                                       zhnumber-gbk.cfg,
                                       zhnumber-big5.cfg,
                                       zhnumber.ins and
                                       README.md (this file).
%&lt;/readme&gt;
%&lt;*internal&gt;
\fi
\begingroup
  \def\temp{LaTeX2e}
\expandafter\endgroup\ifx\temp\fmtname\else
\csname fi\endcsname
%&lt;/internal&gt;
%&lt;*install&gt;

\input ctxdocstrip %

\preamble

    Copyright (C) 2012, 2014-2020, 2022 by Qing Lee &lt;sobenlee@gmail.com&gt;
--------------------------------------------------------------------------

    This work may be distributed and/or modified under the
    conditions of the LaTeX Project Public License, either
    version 1.3c of this license or (at your option) any later
    version. This version of this license is in
       http://www.latex-project.org/lppl/lppl-1-3c.txt
    and the latest version of this license is in
       http://www.latex-project.org/lppl.txt
    and version 1.3 or later is part of all distributions of
    LaTeX version 2005/12/01 or later.

    This work has the LPPL maintenance status "maintained".

    The Current Maintainer of this work is Qing Lee.

--------------------------------------------------------------------------

\endpreamble
\postamble

    This package consists of the file  zhnumber.dtx,
                 and the derived files zhnumber.pdf,
                                       zhnumber.sty,
                                       zhnumber-utf8.cfg,
                                       zhnumber-gbk.cfg,
                                       zhnumber-big5.cfg,
                                       zhnumber.ins and
                                       README.md.
\endpostamble

\generate
  {
%&lt;/install&gt;
%&lt;*internal&gt;
    \usedir{source/latex/zhnumber}
    \file{zhnumber.ins}             {\from{\jobname.dtx}{install}}
%&lt;/internal&gt;
%&lt;*install&gt;
    \usedir{tex/latex/zhnumber}
    \file{zhnumber.sty}             {\from{\jobname.dtx}{package}}
    \usedir{tex/latex/zhnumber/config}
    \file{zhnumber-utf8.cfg}        {\from{\jobname.dtx}{config,utf8}}
 \ctxfile{Big5}{zhnumber-big5.cfg}  {\from{\jobname.dtx}{config,big5}}
 \ctxfile{GBK}{zhnumber-gbk.cfg}    {\from{\jobname.dtx}{config,gbk}}
    \nopreamble\nopostamble
    \usedir{doc/latex/zhnumber}
    \file{README.md}                {\from{\jobname.dtx}{readme}}
  }

\endbatchfile
%&lt;/install&gt;
%&lt;*internal&gt;
\fi
%&lt;/internal&gt;
%&lt;package&gt;\NeedsTeXFormat{LaTeX2e}
%&lt;package&gt;\RequirePackage{expl3}
%&lt;+package|config&gt;\GetIdInfo$Id: zhnumber.dtx 5e8c3fe 2022-07-14 18:53:36 +0800 Qing Lee &lt;sobenlee@gmail.com&gt; $
%&lt;package&gt;  {Typesetting numbers with Chinese glyphs}
%&lt;config&amp;utf8&gt;  {Chinese numerals with UTF8 encoding}
%&lt;config&amp;big5&gt;  {Chinese numerals with Big5 encoding}
%&lt;config&amp;gbk&gt;  {Chinese numerals with GBK encoding}
%&lt;package&gt;\ProvidesExplPackage{\ExplFileName}
%&lt;config&amp;utf8&gt;\ProvidesExplFile{\ExplFileName-utf8.cfg}
%&lt;config&amp;big5&gt;\ProvidesExplFile{\ExplFileName-big5.cfg}
%&lt;config&amp;gbk&gt;\ProvidesExplFile{\ExplFileName-gbk.cfg}
%&lt;package|config&gt;  {\ExplFileDate}{3.0}{\ExplFileDescription}
%&lt;*driver&gt;
\documentclass{ctxdoc}
\SideBySideExampleSet{xrightmargin=.6\linewidth}
\begin{document}
  \DocInput{\jobname.dtx}
  \IndexLayout
  \PrintIndex
\end{document}
%&lt;/driver&gt;
% \fi
%
% \CheckSum{1394}
% \GetFileId{zhnumber.sty}
%
% \title{\bfseries\pkg{zhnumber} å®åŒ…}
% \author{æŽæ¸…\\ \path{sobenlee@gmail.com}}
% \date{\filedate\qquad\fileversion\thanks{\ctexkitrev{\ExplFileVersion}.}}
% \maketitle
%
% \begin{documentation}
%
% \section{ç®€ä»‹}
% \pkg{zhnumber} å®åŒ…ç”¨äºŽå°†é˜¿æ‹‰ä¼¯æ•°å­—æŒ‰ç…§ä¸­æ–‡æ&nbsp;¼å¼è¾“å‡ºã€‚ç›¸æ¯”äºŽ \pkg{CJKnumb}ï¼Œå®ƒæä¾›
% çš„å››ä¸ªæ&nbsp;¼å¼è½¬æ¢å‘½ä»¤ \tn{zhnumber}ï¼Œ\tn{zhdigits}ã€\tn{zhnum} å’Œ \tn{zhdig}
% éƒ½æ˜¯å¯ä»¥é€‚å½“å±•å¼€çš„ï¼Œå¯ä»¥æ­£å¸¸ä½¿ç”¨äºŽ |PDF| ä¹¦ç­¾å’Œäº¤å‰å¼•ç”¨ã€‚
%
% \pkg{zhnumber} æ”¯æŒ |GBK|ï¼Œ|Big5| å’Œ |UTF8| ç¼–ç&nbsp;ï¼Œä¾èµ– \LaTeXiii{} é¡¹ç›®çš„
% \pkg{expl3}ï¼Œ\pkg{xparse} å’Œ \pkg{l3keys2e} å®åŒ…ã€‚
%
% \section{ä½¿ç”¨æ–¹æ³•}
%
% \begin{function}[updated=2022-07-10]{encoding}
%   \begin{syntax}
%     encoding = &lt;GBK|Big5|(UTF8)&gt;
%   \end{syntax}
%   ç”¨äºŽæŒ‡å®šç¼–ç&nbsp;çš„å®åŒ…é€‰é¡¹ï¼Œå¯ä»¥åœ¨è°ƒç”¨å®åŒ…çš„æ—¶å€™è®¾å®šï¼Œä¹Ÿå¯ä»¥ç”¨ \tn{zhnumsetup}
%   åœ¨å¯¼è¨€åŒºå†…è®¾å®šã€‚å¯¹äºŽ \upLaTeXã€\XeLaTeX{} å’Œ \LuaLaTeXï¼Œä¸ç”¨æŒ‡å®šç¼–ç&nbsp;ï¼Œå®åŒ…å°†
%   è‡ªåŠ¨ä½¿ç”¨ |UTF8| ç¼–ç&nbsp;ã€‚åªæœ‰ \LaTeX{} å’Œ \pdfLaTeX{} éœ€è¦æŒ‡å®šç¼–ç&nbsp;ï¼Œå¦‚æžœæ²¡æœ‰æŒ‡å®šï¼Œ
%   é»˜è®¤ä¹Ÿä½¿ç”¨ |UTF8|ã€‚
% \end{function}
%
% \begin{function}[EXP, updated=2022-07-10]{\zhnumber}
%   \begin{syntax}
%     \tn{zhnumber} \Arg{number}
%   \end{syntax}
%   ä»¥ä¸­æ–‡æ&nbsp;¼å¼è¾“å‡ºæ•°å­—ã€‚è¿™é‡Œçš„æ•°å­—å¯ä»¥æ˜¯æ•´æ•°ã€å°æ•°å’Œåˆ†æ•°ã€‚ä¾‹å¦‚
%   \begin{SideBySideExample}
%     \zhnumber{2012020120}\\
%     \zhnumber{2 012 020 120}\\
%     \zhnumber{2,012,020,120}\\
%     \zhnumber{2012.020120}\\
%     \zhnumber{2012.}\\
%     \zhnumber{.2012}\\
%     \zhnumber{20120/20120}\\
%     \zhnumber{/2012}\\
%     \zhnumber{2012/}\\
%     \zhnumber{201;2020/120}
%   \end{SideBySideExample}
% \end{function}
%
% \begin{function}[EXP, updated=2022-07-10]{\zhdigits}
%   \begin{syntax}
%     \tn{zhdigits}   \Arg{number}
%     \tn{zhdigits} * \Arg{number}
%   \end{syntax}
%   å°†é˜¿æ‹‰ä¼¯æ•°å­—è½¬æ¢ä¸ºä¸­æ–‡æ•°å­—ä¸²ã€‚ç¼ºçœçŠ¶æ€ä¸‹ï¼Œ\tn{zhdigits} å°† 0 æ˜&nbsp;å°„ä¸ºã€‡ï¼Œå¦‚æžœéœ€è¦
%   å°†å…¶æ˜&nbsp;å°„ä¸ºé›¶ï¼Œå¯ä»¥ä½¿ç”¨å¸¦æ˜Ÿå·çš„å½¢å¼ã€‚ä¾‹å¦‚
%   \begin{SideBySideExample}
%     \zhdigits{2012020120}\\
%     \zhdigits*{2012020120}
%   \end{SideBySideExample}
% \end{function}
%
% \begin{function}[EXP, updated=2022-07-10]{\zhnum}
%   \begin{syntax}
%     \tn{zhnum} \Arg{counter}
%     \tn{pagenumbering} \{zhnum\}
%   \end{syntax}
%   ä¸Ž |\roman| ç­‰ç±»ä¼¼ï¼Œç”¨äºŽå°† \LaTeX è®¡æ•°å™¨çš„å€¼è½¬æ¢ä¸ºä¸­æ–‡æ•°å­—ã€‚ä¾‹å¦‚
%   \begin{SideBySideExample}
%     \zhnum{section}
%   \end{SideBySideExample}
% \end{function}
%
% \begin{function}[EXP, updated=2022-07-10]{\zhdig}
%   \begin{syntax}
%     \tn{zhdig} \Arg{counter}
%     \tn{pagenumbering} \{zhdig\}
%   \end{syntax}
%   ä¸Ž |\roman| ç­‰ç±»ä¼¼ï¼Œç”¨äºŽå°† \LaTeX è®¡æ•°å™¨çš„å€¼è½¬æ¢ä¸ºä¸­æ–‡æ•°å­—ä¸²ã€‚ä¾‹å¦‚
%   \begin{SideBySideExample}
%     \zhdig{section}
%   \end{SideBySideExample}
% \end{function}
%
% \begin{function}[EXP, updated=2022-07-10]{\zhweekday}
%   \begin{syntax}
%     \tn{zhweekday} \Arg{yyyy/mm/dd}
%   \end{syntax}
%   è¾“å‡ºæ—¥æœŸå½“å¤©çš„æ˜ŸæœŸã€‚ä¾‹å¦‚
%   \begin{SideBySideExample}
%     \zhweekday{2012/5/20}
%   \end{SideBySideExample}
% \end{function}
%
% \begin{function}[EXP, updated=2022-07-10]{\zhdate}
%   \begin{syntax}
%     \tn{zhdate}   \Arg{yyyy/mm/dd}
%     \tn{zhdate} * \Arg{yyyy/mm/dd}
%   \end{syntax}
%   ä»¥ä¸­æ–‡æ&nbsp;¼å¼è¾“å‡ºæ—¥æœŸï¼Œå…¶ä¸­å¸¦ |*| çš„å‘½ä»¤è¿˜è¾“å‡ºæ˜ŸæœŸã€‚ä¾‹å¦‚
%   \begin{SideBySideExample}
%     \zhdate{2012/5/21}\\
%     \zhdate*{2012/5/21}
%   \end{SideBySideExample}
% \end{function}
%
% \begin{function}[EXP, updated=2022-07-10]{\zhtoday}
%   ä¸Ž |\today| ç±»ä¼¼ï¼Œä»¥ä¸­æ–‡è¾“å‡ºå½“å¤©çš„æ—¥æœŸã€‚ä¾‹å¦‚
%   \begin{SideBySideExample}
%     \zhtoday
%   \end{SideBySideExample}
% \end{function}
%
% \begin{function}[EXP, updated=2022-07-10]{\zhtime}
%   \begin{syntax}
%     \tn{zhtime} \Arg{hh:mm}
%   \end{syntax}
%   ä»¥ä¸­æ–‡æ&nbsp;¼å¼è¾“å‡ºæ—¶é—´ã€‚ä¾‹å¦‚
%   \begin{SideBySideExample}
%     \zhtime{23:56}
%   \end{SideBySideExample}
% \end{function}
%
% \begin{function}[EXP, updated=2022-07-10]{\zhcurrtime}
%   è¾“å‡ºå½“å‰çš„æ—¶é—´ã€‚ä¾‹å¦‚
%   \begin{SideBySideExample}
%     \zhcurrtime
%   \end{SideBySideExample}
% \end{function}
%
% \begin{function}[EXP, updated=2022-07-10]{\zhtiangan}
%   \begin{syntax}
%     \tn{zhtiangan} \Arg{number}
%   \end{syntax}
%   è¾“å‡ºå¯¹åº”çš„å¤©å¹²è®¡æ•°ã€‚\meta{number} çš„æ­£å¸¸èŒƒå›´æ˜¯ 1--10ï¼Œè¶…å‡ºèŒƒå›´çš„æ•°å­—å°†è¾“å‡ºç©ºå€¼ã€‚ä¾‹å¦‚
%   \begin{SideBySideExample}[xrightmargin=.4\linewidth]
%     \zhtiangan{1} \zhtiangan{2} \zhtiangan{3}
%     \zhtiangan{4} \zhtiangan{5} \zhtiangan{10}
%   \end{SideBySideExample}
% \end{function}
%
% \begin{function}[EXP, updated=2022-07-10]{\zhdizhi}
%   \begin{syntax}
%     \tn{zhdizhi} \Arg{number}
%   \end{syntax}
%   è¾“å‡ºå¯¹åº”çš„åœ°æ”¯è®¡æ•°ã€‚\meta{number} çš„æ­£å¸¸èŒƒå›´æ˜¯ 1--12ï¼Œè¶…å‡ºèŒƒå›´çš„æ•°å­—å°†è¾“å‡ºç©ºå€¼ã€‚ä¾‹å¦‚
%   \begin{SideBySideExample}[xrightmargin=.4\linewidth]
%     \zhdizhi{1} \zhdizhi{2} \zhdizhi{3}
%     \zhdizhi{4} \zhdizhi{5} \zhdizhi{12}
%   \end{SideBySideExample}
% \end{function}
%
% \begin{function}[EXP, updated=2022-07-10]{\zhganzhi}
%   \begin{syntax}
%     \tn{zhganzhi} \Arg{number}
%   \end{syntax}
%   è¾“å‡ºå¯¹åº”çš„å¹²æ”¯è®¡æ•°ã€‚\meta{number} çš„æ­£å¸¸èŒƒå›´æ˜¯ 1--60ï¼Œè¶…å‡ºèŒƒå›´çš„æ•°å­—å°†è¾“å‡ºç©ºå€¼ã€‚ä¾‹å¦‚
%   \begin{SideBySideExample}[xrightmargin=.4\linewidth]
%     \zhganzhi{1} \zhganzhi{2} \zhganzhi{3} \\
%     \zhganzhi{4} \zhganzhi{5} \zhganzhi{60}
%   \end{SideBySideExample}
% \end{function}
%
% \begin{function}[EXP, updated=2022-07-10]{\zhganzhinian}
%   \begin{syntax}
%     \tn{zhganzhinian} \Arg{year}
%   \end{syntax}
%   è¾“å‡ºå…¬å…ƒçºªå¹´ \meta{year} å¯¹åº”çš„å¹²æ”¯çºªå¹´ã€‚å…¬å…ƒå‰çš„å¹´ä»½ç”¨è´Ÿæ•°è¡¨ç¤ºã€‚ä¾‹å¦‚
%   \begin{SideBySideExample}[xrightmargin=.4\linewidth]
%     \zhganzhinian{1898}  \zhganzhinian{-246} \\
%     \zhganzhinian{-2697} \zhganzhinian{\year}
%   \end{SideBySideExample}
% \end{function}
%
% \begin{function}[added=2012-05-25]{\zhnumExtendScaleMap}
%   \begin{syntax}
%     \tn{zhnumExtendScaleMap} \oarg{character} \{&lt;character_1&gt;, &lt;character_2&gt;, ..., &lt;character_n&gt;\}
%   \end{syntax}
%   ç¼ºçœçŠ¶æ€ä¸‹ \tn{zhnumber} èƒ½æ­£ç¡®ä¸­æ–‡æ&nbsp;¼å¼åŒ–çš„æœ€å¤§æ•´æ•°æ˜¯ $10^{48}-1$ï¼Œ\tn{zhdigits} ä¸å—
%   è¿™ä¸ªå¤§å°çš„é™åˆ¶ã€‚å¯ä»¥é€šè¿‡ \tn{zhnumExtendScaleMap} æ¥æ‰©å±• \tn{zhnumber}ã€‚
%   \meta{character_i} è®¾ç½® $10^{4(i+11)}$ã€‚è‹¥ç»™å‡ºå¯é€‰é¡¹ \meta{character}ï¼Œåˆ™å½“
%   æ•°å­—å¤§äºŽ $10^{4(n+12)}-1$ æ—¶ï¼Œç»Ÿä¸€ç”¨ \meta{character} è®¾ç½®è¾“å‡ºæ•°å­—çš„è¿›ä½ã€‚
% \end{function}
%
% \begin{function}[updated=2022-07-10]{\zhnumsetup}
%   \begin{syntax}
%     \tn{zhnumsetup} \{&lt;key_1&gt;=&lt;val_1&gt;, &lt;key_2&gt;=&lt;val_2&gt;, ...\}
%   \end{syntax}
%   ç”¨äºŽåœ¨å¯¼è¨€åŒºæˆ–æ–‡æ¡£ä¸­ï¼Œè®¾ç½®ä¸­æ–‡æ•°å­—çš„è¾“å‡ºæ&nbsp;¼å¼ã€‚ç›®å‰å¯ä»¥è®¾ç½®çš„ \meta{key} å¦‚ä¸‹ä»‹ç»ã€‚
%   ä»¥\textbf{ç²—ä½“}è¡¨ç¤ºé€‰é¡¹çš„é»˜è®¤å€¼ã€‚
% \end{function}
%
% \begin{function}[added=2012-05-25]{time}
%   \begin{syntax}
%     time = &lt;(Arabic)|Chinese&gt;
%   \end{syntax}
%   è®¾ç½®æ—¥æœŸå’Œæ—¶é—´çš„æ•°å­—æ&nbsp;¼å¼ï¼Œ\meta{Arabic} ä¸ºé˜¿æ‹‰ä¼¯æ•°å­—ï¼Œè€Œ \meta{Chinese} ä¸ºä¸­æ–‡æ•°å­—ã€‚
%   ä¾‹å¦‚
%   \begin{SideBySideExample}
%     \zhnumsetup{time=Chinese}
%     \zhtoday\zhcurrtime
%   \end{SideBySideExample}
% \end{function}
%
% \begin{function}[added=2016-05-01]{arabicsep}
%   \begin{syntax}
%     arabicsep = \Arg{sep}
%   \end{syntax}
%   è®¾ç½®æ—¥æœŸå’Œæ—¶é—´çš„æ•°å­—æ&nbsp;¼å¼ä¸ºé˜¿æ‹‰ä¼¯æ•°å­—æ—¶ï¼Œé˜¿æ‹‰ä¼¯æ•°å­—ä¸Žæ±‰å­—çš„é—´éš”å†…å®¹ã€‚é»˜è®¤ä¸ºä¸€ä¸ªç©ºæ&nbsp;¼ã€‚
% \end{function}
%
% \begin{function}[updated=2012-05-25]{style}
%   \begin{syntax}
%     style = &lt;(Simplified)|Traditional|(Normal)|Financial|Ancient&gt;
%   \end{syntax}
%   æ„ä¹‰åˆ†åˆ«ä¸º
%
%   \begin{description}[font=\mdseries\ttfamily\small,align=right,leftmargin=*,
%                       labelsep=\marginparsep,labelindent=-\marginparsep]
%     \item[Simplified]  ä»¥ç®€ä½“ä¸­æ–‡è¾“å‡ºæ•°å­—ï¼ˆå¯¹ |Big5| ç¼–ç&nbsp;æ—&nbsp;æ•ˆï¼‰ï¼›
%     \item[Traditional] ä»¥ç¹ä½“ä¸­æ–‡è¾“å‡ºæ•°å­—ï¼ˆå¯¹ |Big5| ç¼–ç&nbsp;æ—&nbsp;æ•ˆï¼‰ï¼›
%     \item[Normal] ä»¥å°å†™å½¢å¼è¾“å‡ºä¸­æ–‡æ•°å­—ï¼›
%     \item[Financial]  ä»¥å¤§å†™å½¢å¼è¾“å‡ºä¸­æ–‡æ•°å­—ï¼›
%     \item[Ancient] ä»¥å»¿è¾“å‡º 20ï¼Œä»¥å…è¾“å‡º 30ï¼Œä»¥åŒè¾“å‡º 40ï¼Œä»¥çš•è¾“å‡º 200ã€‚
%   \end{description}
%
%   å¯ä»¥è®¾ç½® |style| ä¸ºå…¶ä¸­ä¸€ä¸ªï¼Œä¹Ÿå¯ä»¥æ˜¯å‰ä¸¤ä¸ªä¸ŽåŽä¸‰ä¸ªçš„é€‚å½“ç»„åˆï¼Œé»˜è®¤æ˜¯ç®€ä½“å°å†™ã€‚ä¾‹å¦‚
%   \begin{SideBySideExample}[xrightmargin=.4\linewidth]
%     \zhnumsetup{style={Traditional,Financial}}
%     \zhnumber{62012.3}\\
%     \zhnumsetup{style=Ancient}
%     \zhnumber{21}
%   \end{SideBySideExample}
% \end{function}
%
% \begin{function}{null}
%   \begin{syntax}
%     null = &lt;\TFF&gt;
%   \end{syntax}
%   ç¼ºçœçŠ¶æ€ä¸‹ï¼Œé™¤äº† \tn{zhdigits} å¤–ï¼Œå…¶ä»–çš„æ&nbsp;¼å¼è½¬æ¢å‘½ä»¤ï¼Œå°† 0 æ˜&nbsp;å°„æˆé›¶ï¼Œå¦‚æžœéœ€è¦å°† 0 æ˜&nbsp;å°„
%   æˆã€‡ï¼Œå¯ä»¥ä½¿ç”¨è¿™ä¸ªé€‰é¡¹ã€‚
% \end{function}
%
% \begin{function}[added=2015-05-20]{ganzhi-cyclic}
%   \begin{syntax}
%     ganzhi-cyclic = &lt;\TFF&gt;
%   \end{syntax}
%   å¤©å¹²ã€åœ°æ”¯å’Œå¹²æ”¯çš„æ•°å­—éƒ½æœ‰ä¸€å®šèŒƒå›´ã€‚è‹¥å‚æ•°å¤§äºŽè¿™ä¸ªèŒƒå›´ï¼Œ\tn{tiangan} ç­‰å°†è¾“å‡ºç©ºå€¼ã€‚
%   å¯ä»¥å°†æœ¬é€‰é¡¹è®¾ç½®ä¸º |true|ï¼Œå¯¹è¶…å‡ºèŒƒå›´çš„æ•°å­—å–ç›¸åº”çš„æ¨¡ã€‚
%   è¯·æ³¨æ„ï¼Œæ•°å­— |0| çš„ç»“æžœæ€»æ˜¯ä¸ºç©ºå€¼ã€‚ä¾‹å¦‚
%   \begin{SideBySideExample}[xrightmargin=.3\linewidth]
%     \zhnumsetup{ganzhi-cyclic}
%     \zhtiangan{11} \zhtiangan{12} \zhtiangan{209}
%     \zhtiangan{-1} \zhtiangan{-2} \zhtiangan{-683} \\
%     \zhdizhi{13}   \zhdizhi{24}   \zhdizhi{1211}
%     \zhdizhi{-1}   \zhdizhi{-2}   \zhdizhi{-8199}  \\
%     \zhganzhi{61}  \zhganzhi{72}  \zhganzhi{2158}  \\
%     \zhganzhi{-1}  \zhganzhi{-2}  \zhganzhi{-789}
%   \end{SideBySideExample}
% \end{function}
%
% \pkg{zhnumber} æä¾›ä¸‹åˆ—é€‰é¡¹æ¥æŽ§åˆ¶é˜¿æ‹‰ä¼¯æ•°å­—çš„ä¸­æ–‡æ˜&nbsp;å°„ã€‚
% \begin{frameverb}
%   - -0 0 1 2 3 4 5 6 7 8 9 10 20 30 40 100 200 1000
%   E2 E3 E4 E8 E12 E16 E20 E24 E28 E32 E36 E40 E44
%   F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F100 F1000 FE2 FE3
%   T1 T2 T3 T4 T5 T6 T7 T8 T9 T10
%   D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11 D12
%   GZ1 GZ2 GZ3 GZ4 GZ5 GZ6 GZ7 GZ8 GZ9 GZ10 ... GZ60
%   dot and parts
%   year month day hour minute weekday mon tue wed thu fri sat sun
% \end{frameverb}
% å…¶ä¸­ |-| è®¾ç½®è´Ÿï¼Œ|-0| è®¾ç½®ã€‡ï¼Œ|dot| è®¾ç½®å°æ•°çš„ç‚¹ï¼Œ|and| å’Œ |parts| åˆ†åˆ«è®¾ç½®åˆ†æ•°
% çš„â€œåˆâ€å’Œâ€œåˆ†ä¹‹â€ï¼Œ|E|$n$ è®¾ç½® $10^n$ï¼Œ|F|$n$ è®¾ç½®æ•°å­— $n$ çš„å¤§å†™ï¼Œ|T|$n$ è®¾ç½®
% æ•°å­— $n$ çš„å¤©å¹²ï¼Œ|D|$n$ è®¾ç½®æ•°å­— $n$ çš„åœ°æ”¯ï¼Œè€Œ |GZ|$n$ è®¾ç½®æ•°å­— $n$ çš„å¹²æ”¯ã€‚
% å…¶ä»–çš„é€‰é¡¹åŒå­—é¢æ„æ€ï¼Œä¸å†èµ˜è¿°ã€‚ä¾‹å¦‚
% \begin{frameverb}
%   \zhnumsetup{2={ä¸¤}}
% \end{frameverb}
% å¯ä»¥å°† 2 æ˜&nbsp;å°„æˆä¸¤ã€‚éœ€è¦è¯´æ˜Žçš„æ˜¯ï¼Œ\pkg{zhnumber} å°†ä¼˜å…ˆä½¿ç”¨è¿™é‡Œçš„è®¾ç½®ï¼Œæ‰€ä»¥å¯èƒ½ä¼šå½±å“
% åˆ° |style| é€‰é¡¹ã€‚å¦‚æžœè¦æ¢å¤ |style| çš„åŠŸèƒ½ï¼Œå¯ä»¥ä½¿ç”¨ |reset| é€‰é¡¹ã€‚
%
% \begin{function}[updated=2022-07-10]{reset}
%   \begin{syntax}
%     reset
%   \end{syntax}
%   ç”¨äºŽæ¢å¤ \pkg{zhnumber} å¯¹é˜¿æ‹‰ä¼¯æ•°å­—çš„åˆå§‹åŒ–æ˜&nbsp;å°„ã€‚\pkg{zhnumber} çš„ä¸­æ–‡æ•°å­—åˆå§‹åŒ–
%   è®¾ç½®è§æºä»£ç&nbsp;ï¼ˆç¬¬ \ref{sec:zhnum-map} èŠ‚ï¼‰ã€‚
% \end{function}
%
% \begin{function}[added=2014-09-09]{activechar}
%   \begin{syntax}
%     activechar = &lt;\TTF&gt;
%   \end{syntax}
%   åœ¨ \LaTeX{} æˆ–è€… \pdfLaTeX{} ä¸‹é¢è¾“å‡ºæ±‰å­—ï¼Œä¼&nbsp;ç»Ÿçš„åŠžæ³•éœ€è¦å°†æ±‰å­—çš„é¦–å­—èŠ‚è®¾ç½®ä¸º
%   æ´»åŠ¨å­—ç¬¦ï¼Œç„¶åŽå†é€šè¿‡ç‰¹æ®Šçš„å®æŠ€å·§æ¥å®žçŽ°ã€‚å›&nbsp;æ­¤ï¼Œ\pkg{zhnumber} åœ¨è½½å…¥é…ç½®æ–‡ä»¶çš„
%   æ—¶å€™ï¼Œé»˜è®¤ä¼šå°†æ±‰å­—çš„é¦–å­—èŠ‚è®¾ç½®ä¸ºæ´»åŠ¨å­—ç¬¦ã€‚ç¦ç”¨æœ¬é€‰é¡¹å°†ä¸ä¼šæ”¹å˜æ±‰å­—é¦–å­—èŠ‚çš„
%   ç±»ä»£ç&nbsp;ã€‚éœ€è¦åœ¨æœ¬é€‰é¡¹ä¹‹åŽï¼Œä½¿ç”¨ \texttt{encoding} æˆ–è€… \texttt{reset} é€‰é¡¹
%   æ‰ä¼šæœ‰æ•ˆæžœã€‚
% \end{function}
%
% \begin{function}[updated=2022-07-10]{\zhnumber,\zhdigits,\zhnum,\zhdig}
%   \begin{syntax}
%     \tn{zhnumber}   \oarg{options} \Arg{number}
%     \tn{zhdigits} * \oarg{options} \Arg{number}
%     \tn{zhnum}      \oarg{options} \Arg{counter}
%     \tn{zhdig}      \oarg{options} \Arg{counter}
%   \end{syntax}
%   å¦‚æžœåªæ”¹å˜å½“å‰æ•°å­—çš„ä¸­æ–‡è¾“å‡ºæ&nbsp;¼å¼ï¼Œå¯ä»¥ä½¿ç”¨å¸¦é€‰é¡¹çš„æ&nbsp;¼å¼è½¬æ¢å‘½ä»¤ï¼Œå…¶ä¸­ \meta{options}
%   ä¸Ž \tn{zhnumsetup} çš„å‚æ•°ç›¸åŒï¼Œå¦‚ä¸Šæ‰€ä»‹ç»ã€‚è¿™äº›å¸¦äº†é€‰é¡¹çš„å‘½ä»¤æ˜¯ä¸å¯å±•å¼€çš„ï¼Œåœ¨æŸäº›åœºåˆä½¿
%   ç”¨æ—¶è¦å°å¿ƒã€‚
% \end{function}
%
% \end{documentation}
%
% \StopEventually{}
%
% \begin{implementation}
%
% \section{\pkg{zhnumber} å®åŒ…ä»£ç&nbsp;å®žçŽ°}
%
%    \begin{macrocode}
%&lt;*package&gt;
%    \end{macrocode}
%
%    \begin{macrocode}
%&lt;@@=zhnum&gt;
%    \end{macrocode}
%
%    \begin{macrocode}
\msg_new:nnn { zhnumber } { l3-too-old }
  {
    Support~package~'expl3'~too~old. \\\\
    Please~update~an~up~to~date~version~of~the~bundles\\\\
    'l3kernel'~and~'l3packages'\\\\
    using~your~TeX~package~manager~or~from~CTAN.
  }
\@ifpackagelater { expl3 } { 2019/03/05 } { }
  { \msg_error:nn  { zhnumber }  { l3-too-old } }
%    \end{macrocode}
%
%    \begin{macrocode}
\cs_if_exist:NF \NewDocumentCommand
  { \RequirePackage { xparse } }
%    \end{macrocode}
%
% \begin{macro}{\zhnum_output:n,\zhnum_expand_wrap:wn}
% å—ç›ŠäºŽ \tn{tex_expanded:D}ï¼Œæˆ‘ä»¬ä½¿ç”¨å¦‚ä¸‹çš„ç»“æž„ç®€å•å®žçŽ° |f| å±•å¼€ã€‚
% \begin{verbatim}
%   \exp_not:e
%     {
%       ...
%       \exp_not:o { &lt;tl_var&gt; }
%       ...
%       \exp_not:o { &lt;tl_var&gt; }
%       ...
%       \exp_not:o { &lt;tl_var&gt; }
%       ...
%     }
% \end{verbatim}
% å¹¶ä¸”å¯ä»¥å°† \tn{zhnumber} ç­‰æ—&nbsp;é£Žé™©åœ°ä½¿ç”¨äºŽè¯¸å¦‚ \tn{edef} å®šä¹‰ç­‰å®Œå…¨å±•å¼€çš„åœºåˆã€‚
% ä»Ž \TeXLive\ 2019 å¼€å§‹ï¼Œå„ä¸ªä¸»è¦å¼•æ“Žéƒ½å·²ç»æ”¯æŒ \tn{tex_expanded:D}ï¼Œ
% å¯¹äºŽè¾ƒæ—©çš„ç‰ˆæœ¬ï¼Œ\LaTeXiii\ ä¹Ÿå®žçŽ°äº†ä¸€ä¸ªæ¨¡æ‹Ÿã€‚
%    \begin{macrocode}
\cs_new:Npn \zhnum_output:n #1
  { \exp_args:Nc \zhnum_exp_not:o { l_@@_ #1 _tl } }
\cs_new_protected:Npn \zhnum_expand_wrap:wn #1#
  { \@@_expand_wrap_aux:nn {#1} }
\cs_new_protected:Npn \@@_expand_wrap_aux:nn #1#2
  { #1 { \exp_not:e {#2} } }
\cs_new_eq:NN \zhnum_exp_not:e \exp_not:e
\cs_new_eq:NN \zhnum_exp_not:o \exp_not:o
%    \end{macrocode}
% ä½†è¿™ç§æ–¹å¼ä¹Ÿæœ‰ä¸€å®šçš„ç¼ºç‚¹ï¼Œæ¯”å¦‚åœ¨ \pdfTeX\ å¼•æ“Žä¸‹ï¼Œ\pkg{hyperref} åŒ…çš„
% \tn{pdfstringdef} å°±éœ€è¦æŠŠæ±‰å­—é¦–å­—èŠ‚çš„æ´»åŠ¨å­—ç¬¦å±•å¼€ï¼Œ
% å¹¶ä½œé€‚å½“çš„é‡å®šä¹‰åŽæ‰èƒ½å¾—åˆ°é¢„æœŸçš„ç»“æžœã€‚ä¸ºæ­¤ï¼Œæˆ‘ä»¬å®šä¹‰ä¸€ä¸ªæ¸…é™¤å‘½ä»¤ï¼Œä¸ä½¿ç”¨ä»¥ä¸Šæœºåˆ¶ã€‚
%    \begin{macrocode}
\cs_new_protected:Npn \zhnumClearWrapper
  {
    \cs_set_eq:NN \zhnum_exp_not:e \use:n
    \cs_set_eq:NN \zhnum_exp_not:o \use:n
  }
\cs_new_protected:Npn \zhnumResetWrapper
  {
    \cs_set_eq:NN \zhnum_exp_not:e \exp_not:e
    \cs_set_eq:NN \zhnum_exp_not:o \exp_not:o
  }
\hook_gput_code:nnn { package/CJKutf8/after } { zhnumber }
  { \g@addto@macro \pdfstringdefPreHook { \zhnumClearWrapper } }
\hook_gput_code:nnn { package/xCJK2uni/after } { zhnumber }
  { \g@addto@macro \pdfstringdefPreHook { \zhnumClearWrapper } }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhnumber}
% ç”¨äºŽå°†è¾“å…¥çš„æ•°å­—æŒ‰ç…§ä¸­æ–‡æ&nbsp;¼å¼è¾“å‡ºã€‚
%    \begin{macrocode}
\NewExpandableDocumentCommand \zhnumber { +o +m }
  {
    \tl_if_novalue:nTF {#1}
      { \zhnum_number:e }
      { \zhnumberwithoptions {#1} }
    {#2}
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnumberwithoptions}
% å¸¦é€‰é¡¹çš„ç”¨æˆ·å‡½æ•°ã€‚
%    \begin{macrocode}
 \NewDocumentCommand \zhnumberwithoptions { +m +m }
  {
    \group_begin:
      \zhnum_set:n {#1}
      \zhnum_number:e {#2}
    \group_end:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_number:n}
% \begin{macro}{\@@_number:www}
% å…ˆåˆ¤æ–­è¾“å…¥çš„æ˜¯å°æ•°è¿˜æ˜¯åˆ†æ•°ã€‚
%    \begin{macrocode}
\zhnum_expand_wrap:wn
\cs_new:Npn \zhnum_number:n #1
  { \@@_number:www #1 . \q_nil . \q_stop }
\cs_new:Npn \@@_number:www #1 . #2 . #3 \q_stop
  {
    \quark_if_nil:nTF {#2}
      { \@@_integer_or_fraction:www #1 / \q_nil / \q_stop }
      { \zhnum_decimal:nn {#1} {#2} }
  }
\cs_generate_variant:Nn \zhnum_number:n { e }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@@_integer_or_fraction:www}
% åˆ¤æ–­æ˜¯å¦è¾“å…¥çš„æ˜¯åˆ†æ•°ã€‚
%    \begin{macrocode}
\cs_new:Npn \@@_integer_or_fraction:www #1 / #2 / #3 \q_stop
  {
    \quark_if_nil:nTF {#2}
      { \zhnum_integer:n {#1} }
      { \@@_fraction:wwww #2 \q_mark #1 ; \q_nil ; \q_stop }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_fraction:wwww}
% å¯¹åˆ†æ•°è¿›è¡Œé¢„å¤„ç†ã€‚
%    \begin{macrocode}
\cs_new:Npn \@@_fraction:wwww #1 \q_mark #2 ; #3 ; #4 \q_stop
  {
    \quark_if_nil:nTF {#3}
      {
        \zhnum_blank_to_zero:n {#1}
        \zhnum_output:n { parts }
        \zhnum_blank_to_zero:n {#2}
      }
      {
        \tl_if_blank:nF {#2}
          {
            \zhnum_number:n {#2}
            \zhnum_output:n { and }
          }
        \zhnum_blank_to_zero:n {#1}
        \zhnum_output:n { parts }
        \zhnum_blank_to_zero:n {#3}
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_decimal:nn}
% å¯¹å°æ•°è¿›è¡Œé¢„å¤„ç†ã€‚
%    \begin{macrocode}
\cs_new:Npn \zhnum_decimal:nn #1#2
  {
    \zhnum_blank_to_zero:n {#1}
    \zhnum_output:n { dot }
    \tl_if_blank:nTF {#2}
      { \zhnum_output:n { 0 } }
      { \zhnum_digits_zero:n {#2} }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_blank_to_zero:n}
% è¾“å‡ºå°æ•°çš„æ•´æ•°ä½ã€‚
%    \begin{macrocode}
\cs_new:Npn \zhnum_blank_to_zero:n #1
  {
    \tl_if_blank:nTF {#1}
      { \zhnum_output:n { 0 } }
      { \zhnum_number:n {#1} }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhnum,\zhnumberwithoptions}
% ç”¨äºŽå°† \LaTeX{} è®¡æ•°å™¨æŒ‰ä¸­æ–‡æ&nbsp;¼å¼è¾“å‡ºã€‚
%    \begin{macrocode}
\NewExpandableDocumentCommand \zhnum { +o +m }
  {
    \tl_if_novalue:nTF {#1}
      { \zhnum_counter:n }
      { \zhnumwithoptions {#1} }
    {#2}
  }
\NewDocumentCommand \zhnumwithoptions { +m +m }
  {
    \group_begin:
      \zhnum_set:n {#1}
      \zhnum_counter:n {#2}
    \group_end:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_counter:n, \zhnum_int:n}
% å¯ä»¥ç›´æŽ¥é€šè¿‡æ¯”è¾ƒ \LaTeX{} è®¡æ•°å™¨çš„å€¼æ¥å¾—åˆ°ç¬¦å·å’Œç»å¯¹å€¼ã€‚
%    \begin{macrocode}
\cs_new:Npn \zhnum_counter:n #1
  {
    \int_if_exist:cTF { c@#1 }
      { \exp_args:Nc \zhnum_int:n { c@#1 } }
      { \@@_counter_error:n {#1} }
  }
\cs_new:Npn \@@_counter_error:n #1
  { \msg_expandable_error:nnn { zhnumber } { not-counter } {#1} }
\msg_new:nnn  { zhnumber } { not-counter }
  { `#1'~is~not~a~LaTeX~counter. }
\zhnum_expand_wrap:wn
\cs_new:Npn \zhnum_int:n #1
  {
    \int_compare:nNnTF {#1} &gt; \c_zero_int
      { \zhnum_parse_number:f { \int_eval:n {#1} } }
      {
        \int_compare:nNnTF {#1} &lt; \c_zero_int
          {
            \zhnum_output:n { minus }
            \zhnum_parse_number:f { \int_eval:n { - #1 } }
          }
          { \zhnum_output:n { 0 } }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\@zhnum}
% ç”¨äºŽæ”¯æŒ |\pagenumbering{zhnum}|ã€‚
%    \begin{macrocode}
\cs_new:Npn \@zhnum { \zhnum_int:n }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_integer:n}
% å¯¹æ•´æ•°çš„å¤„ç†ã€‚è¿™ä¸ªå‡½æ•°åŸºæœ¬æŠ„å½•è‡ª \pkg{l3bigint} çš„ \cs{__bingint_read_do:nn}ã€‚å®ƒå¯ä»¥
% æ­£ç¡®å–å¾—ç¬¦å·ï¼ŒåŽ»æŽ‰å¤šä½™çš„é›¶ï¼Œè¿˜å¯ä»¥å¾ªçŽ¯å±•å¼€æ•°å­—ã€‚ä½†å®ƒåœ¨é‡åˆ°éžæ•°å­—çš„æ—¶å€™å°±åœæ­¢äº†
% å¾ªçŽ¯ï¼Œæˆ‘ä»¬å¯èƒ½éœ€è¦éžæ•°å­—ï¼ˆä¾‹å¦‚é€—å·ï¼‰æ¥ä½œä¸ºåˆ†éš”ç¬¦å·ã€‚å›&nbsp;æ­¤å¯¹å®ƒç•¥ä½œä¿®æ”¹ï¼Œè·³è¿‡éžæ•°å­—ã€‚
%    \begin{macrocode}
\cs_new:Npn \zhnum_integer:n #1
  {
    \exp_after:wN \@@_read_integer:www
    \int_value:w
      \exp_after:wN \@@_read_sign_loop:N
      \exp:w \exp_end_continue_f:w \use:n
      #1 \exp_stop_f: \q_recursion_tail \q_recursion_stop
         \@@_result:nn { \c_zero_int } { } ;
  }
\cs_new:Npn \@@_read_sign_loop:N #1
  {
    \if:w + \if:w - \exp_not:N #1 + \fi: \exp_not:N #1
      \exp_after:wN \@@_read_sign_loop:N
      \exp:w \exp_end_continue_f:w \exp_after:wN \use:n
    \else:
      1 \exp_after:wN ;
      \exp:w \exp_end_continue_f:w
        \exp_after:wN \@@_read_zeros_loop:N
        \exp_after:wN #1
    \fi:
  }
\cs_new:Npn \@@_read_zeros_loop:N #1
  {
    \if:w 0 \exp_not:N #1
      \exp_after:wN \@@_read_zeros_loop:N
      \exp:w \exp_end_continue_f:w \exp_after:wN \use:n
    \else:
      \exp_after:wN \@@_read_abs_loop:Nw
      \exp_after:wN #1
    \fi:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_read_abs_loop:Nw}
% å½“æ•°å­—å¾ˆå¤§æ—¶ï¼Œ\pkg{l3bigint} çš„å®žçŽ°ä¼šé€&nbsp;æˆ \TeX{} å†…å­˜æº¢å‡ºï¼š
% \begin{verbatim}
%   ! TeX capacity exceeded, sorry [expansion depth=10000].
% \end{verbatim}
% æˆ‘ä»¬åœ¨è¿™é‡Œå‚è€ƒ \cs{__tl_act:NNNnn} çš„å®žçŽ°å¯¹å®ƒè¿›è¡Œäº†æ”¹è¿›ã€‚
%    \begin{macrocode}
\cs_new:Npn \@@_read_abs_loop:Nw #1#2 \q_recursion_stop
  {
    \zhnum_if_digit:NTF #1
      { \@@_output:nnwnn { + 1 } #1 }
      { \quark_if_recursion_tail_stop_do:Nn #1 { \@@_loop_end:wnn } }
    \exp_after:wN \@@_read_abs_loop:Nw
      \exp:w \exp_end_continue_f:w \use:n #2 \q_recursion_stop
  }
\cs_new:Npn \@@_output:nnwnn #1#2#3 \@@_result:nn #4#5
  { #3 \@@_result:nn { #4#1 } { #5#2 } }
\cs_new:Npn \@@_loop_end:wnn #1 \@@_result:nn #2#3
  { \int_eval:n {#2} ; #3 }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_read_integer:www}
% |#1| ç¬¦å·ï¼Œ|#3| æ˜¯ç»å¯¹å€¼ï¼Œ|#2| æ˜¯ç»å¯¹å€¼çš„é•¿åº¦ã€‚
%    \begin{macrocode}
\cs_new:Npn \@@_read_integer:www #1 ; #2 ; #3 ;
  {
    \int_compare:nNnTF {#2} = \c_zero_int
      { \zhnum_output:n { 0 } }
      {
        \int_compare:nNnF {#1} = \c_one_int
          { \zhnum_output:n { minus } }
        \zhnum_parse_number:nn {#2} {#3}
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_if_digit:NTF}
% åˆ¤æ–­ |#1| æ˜¯å¦ä¸ºæ•°å­—ä½ã€‚
%    \begin{macrocode}
\cs_new:Npn \zhnum_if_digit:NTF #1
  {
    \if_int_compare:w 9 &lt; 1 \exp_not:N #1 \exp_stop_f:
      \exp_after:wN \use_i:nn
    \else:
      \exp_after:wN \use_ii:nn
    \fi:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]
%   {
%     \zhnum_parse_number:n,
%     \zhnum_parse_number:nn
%   }
%    \begin{macrocode}
\cs_new:Npn \zhnum_parse_number:n #1
  { \exp_args:Nf \zhnum_parse_number:nn { \tl_count:n {#1} } {#1} }
\cs_new:Npn \zhnum_parse_number:nn #1
  { \exp_args:Nf \@@_parse_number:nnn { \int_mod:nn {#1} { 4 } } {#1} }
\cs_new:Npn \@@_parse_number:nnn #1#2
  {
    \int_compare:nNnTF {#2} &lt; 2
      { \zhnum_output:n }
      {
        \int_compare:nNnTF {#1} = \c_zero_int
          { \zhnum_split_number:fn { \int_eval:n { #2 / 4 - 1 } } }
          { \@@_split_number_aux:nnn {#1} {#2} }
      }
  }
\cs_generate_variant:Nn \zhnum_parse_number:n { f }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_split_number_aux:nnn}
% ä¸ºäº†å¤„ç†çš„æ–¹ä¾¿ï¼Œåœ¨æ•´æ•°å‰é¢è¡¥ä¸Šé€‚å½“çš„ $0$ï¼Œä½¿å…¶ä½æ•°å¯ä»¥è¢« $4$ æ•´é™¤ã€‚
%    \begin{macrocode}
\cs_new:Npn \@@_split_number_aux:nnn #1#2
  {
    \exp_after:wN \@@_split_number_aux:wwn
      \int_value:w \int_div_truncate:nn {#2} { 4 }
        \if_case:w #1 \exp_stop_f:
          \or: \exp_after:wN \use:n
          \or: \exp_after:wN \use_i_ii:nnn
          \or: \exp_after:wN \use_i:nnn
        \fi:
        { \exp_stop_f: ; 0 } 0 0 ;
  }
\cs_new:Npn \@@_split_number_aux:wwn #1 ; #2 ; #3
  { \zhnum_split_number:nn {#1} { #2#3 } }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_split_number:nn}
% æœ€åŽåŠ&nbsp;å…¥çš„ \cs{q_recursion_tail} æ˜¯åœæ­¢é€’å½’çš„æ&nbsp;‡å¿—ï¼Œè€Œ \cs{q_nil} ç”¨äºŽå&nbsp;ä½ã€‚
%    \begin{macrocode}
\cs_new:Npn \zhnum_split_number:nn #1#2
  {
    \zhnum_split_number:NNnNNNNw \c_true_bool \c_true_bool {#1}
      #2 \q_recursion_tail \q_nil \q_nil \q_nil \q_recursion_stop
  }
\cs_generate_variant:Nn \zhnum_split_number:nn { f }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_split_number:NNnNNNNw}
% å°†è¾“å…¥çš„æ•´æ•°ç”±é«˜ä½åˆ°ä½Žä½ï¼Œä»¥å››ä½ä¸ºä¸€æ®µè¿›è¡Œå¤„ç†ã€‚
%    \begin{macrocode}
\cs_new:Npn \zhnum_split_number:NNnNNNNw #1#2#3#4#5#6#7
  {
    \quark_if_recursion_tail_stop:N #4
    \int_compare:nNnTF { #4#5#6#7 } = \c_zero_int
      { \use_i:nn }
      {
        \bool_if:NF #1 { \zhnum_output:n { 0 } }
        \zhnum_process_number:NNNNNN #4#5#6#7#1#2
        \zhnum_scale_map:n {#3}
        \int_compare:nNnTF {#7} = \c_zero_int
      }
      { \zhnum_split_number:NNfNNNNw \c_false_bool \c_true_bool }
      { \zhnum_split_number:NNfNNNNw \c_true_bool  \c_false_bool }
    { \int_eval:n { #3 - 1 } }
  }
\cs_generate_variant:Nn \zhnum_split_number:NNnNNNNw { NNf }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_process_number:NNNNNN}
% å¯¹å››ä½æ•°å­—æŒ‰æƒ…å†µè¿›è¡Œå¤„ç†ã€‚
%    \begin{macrocode}
\cs_new:Npn \zhnum_process_number:NNNNNN #1#2#3#4#5#6
  {
    \int_compare:nNnTF {#1} = \c_zero_int
      {
        \bool_if:NF #6
          { \zhnum_output:n { 0 } }
      }
      {
        \zhnum_output:n {#1}
        \zhnum_output:n { 1000 }
      }
    \int_compare:nNnTF {#2} = \c_zero_int
      {
        \int_compare:nNnF { #1 * (#3#4) } = \c_zero_int
          { \zhnum_output:n { 0 } }
      }
      {
        \int_compare:nNnTF {#2} = 2
          { \zhnum_output:n { 200 } }
          {
            \zhnum_output:n {#2}
            \zhnum_output:n { 100 }
          }
      }
    \int_compare:nNnTF {#3} = \c_zero_int
      {
        \int_compare:nNnF { #2 * #4 } = \c_zero_int
          { \zhnum_output:n { 0 } }
      }
      {
        \bool_lazy_all:nTF
          {
            { \int_compare_p:nNn {#3}   = \c_one_int }
            { \int_compare_p:nNn {#1#2} = \c_zero_int }
            {#6}
            {#5}
          }
          { \zhnum_output:n { 10 } }
          {
            \int_compare:nTF { 1 &lt; #3 &lt; 5 }
              { \zhnum_output:n { #3 0 } }
              {
                \zhnum_output:n {#3}
                \zhnum_output:n { 10 }
              }
          }
      }
    \int_compare:nNnF {#4} = \c_zero_int
      { \zhnum_output:n {#4} }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhdig}
% ç”¨äºŽå°† \LaTeX{} è®¡æ•°å™¨æŒ‰ä¸­æ–‡æ•°å­—ä¸²è¾“å‡ºã€‚
%    \begin{macrocode}
\NewExpandableDocumentCommand \zhdig { +o +m }
  {
    \tl_if_novalue:nTF {#1}
      { \zhnum_digits_counter:n }
      { \zhdigwithoptions {#1} }
    {#2}
  }
\NewDocumentCommand \zhdigwithoptions { +m +m }
  {
    \group_begin:
      \zhnum_set:n {#1}
      \zhnum_digits_counter:n #1 {#2}
    \group_end:
  }
\cs_new:Npn \zhnum_digits_counter:n #1
  {
    \int_if_exist:cTF { c@#1 }
      { \zhnum_digits_null:v { c@#1 } }
      { \@@_counter_error:n {#1} }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\@zhdig}
% ç”¨äºŽæ”¯æŒ |\pagenumbering{zhdig}|ã€‚
%    \begin{macrocode}
\cs_new:Npn \@zhdig #1
  { \zhnum_digits_null:f { \int_eval:n {#1} } }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhdigits,\zhdigitswithoptions}
% å°†è¾“å…¥çš„æ•°å­—è¾“å‡ºä¸ºä¸­æ–‡æ•°å­—ä¸²è¾“å‡ºã€‚
%    \begin{macrocode}
\NewExpandableDocumentCommand \zhdigits { +s +o +m }
  {
    \tl_if_novalue:nTF {#2}
      { \zhnum_digits:Ne #1 }
      { \zhdigitswithoptions {#1} {#2} }
    {#3}
  }
\NewDocumentCommand \zhdigitswithoptions { +m +m +m }
  {
    \group_begin:
      \zhnum_set:n {#2}
      \zhnum_digits:Ne #1 {#3}
    \group_end:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_digits_zero:n,\zhnum_digits_null:n}
% å¿«æ·æ–¹å¼ã€‚
%    \begin{macrocode}
\cs_new:Npn \zhnum_digits_zero:n
  { \zhnum_digits:Nn \c_true_bool }
\cs_new:Npn \zhnum_digits_null:n
  { \zhnum_digits:Nn \c_false_bool }
\cs_generate_variant:Nn \zhnum_digits_null:n { v , f }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_digits:Nn}
% ä¸Ž \cs{zhnum_integer:n} ç±»ä¼¼ï¼Œä½†ä¸ç”¨åŽ»æŽ‰å¤šä½™çš„é›¶ã€‚
%    \begin{macrocode}
\zhnum_expand_wrap:wn
\cs_new:Npn \zhnum_digits:Nn #1#2
  {
    \exp_after:wN \@@_read_digits:w
    \int_value:w
      \exp_after:wN \@@_read_sign_loop:NN \exp_after:wN #1
      \exp:w \exp_end_continue_f:w \use:n
      #2 \exp_stop_f: \q_recursion_tail \q_recursion_stop
  }
\cs_new:Npn \@@_read_sign_loop:NN #1#2
  {
    \if:w + \if:w - \exp_not:N #2 + \fi: \exp_not:N #2
      \exp_after:wN \@@_read_sign_loop:NN \exp_after:wN #1
      \exp:w \exp_end_continue_f:w \exp_after:wN \use:n
    \else:
      1 \exp_after:wN ;
        \exp_after:wN \@@_read_digits_loop:NN
        \exp_after:wN #1
        \exp_after:wN #2
    \fi:
  }
\cs_new:Npn \@@_read_digits_loop:NN #1#2
  {
    \zhnum_if_digit:NTF #2
      { \@@_output_digits:NN #1#2 }
      {
        \quark_if_recursion_tail_stop:N #2
        \token_if_eq_charcode:NNT #2 .
          { \zhnum_output:n { dot } }
      }
    \exp_after:wN \@@_read_digits_loop:NN \exp_after:wN #1
      \exp:w \exp_end_continue_f:w \use:n
  }
\cs_new:Npn \@@_read_digits:w #1 ;
  {
    \int_compare:nNnF {#1} = \c_one_int
      { \zhnum_output:n { minus } }
  }
\cs_new:Npn \@@_output_digits:NN #1#2
  {
    \zhnum_output:n
      {
        \if_int_compare:w #2 = \c_zero_int
          \bool_if:NTF #1 { zero } { null }
        \else:
          #2
        \fi:
      }
  }
\cs_generate_variant:Nn \zhnum_digits:Nn { Ne }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhdate}
% è¾“å‡ºä¸­æ–‡æ—¥æœŸã€‚
%    \begin{macrocode}
\NewExpandableDocumentCommand \zhdate { +s +m }
  {
    \@@_date:www #2 \q_stop
    \bool_if:NT #1 { \@@_week_day:www #2 \q_stop }
  }
\cs_new:Npn \@@_date:www #1/#2/#3 \q_stop
  { \@@_date_aux:nnn {#1} {#2} {#3} }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhtoday}
% è¾“å‡ºå½“å¤©æ—¥æœŸã€‚
%    \begin{macrocode}
\cs_new:Npn \zhtoday
  {
    \@@_date_aux:nnn
      { \int_value:w \tex_year:D }
      { \tex_month:D }
      { \tex_day:D }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_date_aux:nnn}
%    \begin{macrocode}
\cs_new:Npn \@@_date_aux:nnn
  {
    \bool_if:NTF \l_@@_time_bool
      { \@@_date_aux:NNnnnn \zhnum_digits_null:n \zhnum_int:n { } }
      { \@@_date_aux:Nnnnn \int_to_arabic:n { \l_@@_arabic_sep_tl } }
  }
\cs_new:Npn \@@_date_aux:Nnnnn #1#2
  { \@@_date_aux:NNnnnn #1#1 { \zhnum_exp_not:o {#2} } }
\zhnum_expand_wrap:wn
\cs_new:Npn \@@_date_aux:NNnnnn #1#2#3#4#5#6
  {
    #1 {#4} #3 \zhnum_output:n { year }  #3
    #2 {#5} #3 \zhnum_output:n { month } #3
    #2 {#6} #3 \zhnum_output:n { day }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhweekday}
% è¾“å‡ºæ˜ŸæœŸ
%    \begin{macrocode}
\cs_new:Npn \zhweekday #1
  { \@@_week_day:www #1 \q_stop }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_week_day:www}
% ç”¨ Zeller å…¬å¼è®¡ç®—çš„ç»“æžœ $h$ ä¸Žå®žé™…æ˜ŸæœŸçš„å…³ç³»æ˜¯ $d=h+5\pmod7+1$ã€‚
%    \begin{macrocode}
\zhnum_expand_wrap:wn
\cs_new:Npn \@@_week_day:www #1/#2/#3 \q_stop
  {
    \if_case:w \zhnum_Zeller:nnn {#1} {#2} {#3} \exp_stop_f:
           \zhnum_output:n { sat }
      \or: \zhnum_output:n { sun }
      \or: \zhnum_output:n { mon }
      \or: \zhnum_output:n { tue }
      \or: \zhnum_output:n { wed }
      \or: \zhnum_output:n { thu }
      \or: \zhnum_output:n { fri }
    \fi:
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_Zeller:nnn,\zhnum_Zeller_aux:Nnnn,\zhnum_two_digits:n}
% ç”¨ Zeller å…¬å¼\footnote{\url{http://en.wikipedia.org/wiki/Zeller's_congruence}}
% è®¡ç®—æ˜ŸæœŸå‡&nbsp;ã€‚
%    \begin{macrocode}
\cs_new:Npn \zhnum_Zeller:nnn #1#2#3
  {
    \int_compare:nNnTF
      { #1 \zhnum_two_digits:n {#2} \zhnum_two_digits:n {#3} } &gt; { 1582 10 04 }
      { \@@_Zeller_aux:Nnnn \zhnum_Zeller_Gregorian:nnn }
      { \@@_Zeller_aux:Nnnn \zhnum_Zeller_Julian:nnn }
    {#1} {#2} {#3}
  }
\cs_new:Npn \@@_Zeller_aux:Nnnn  #1#2#3#4
  {
    \int_compare:nNnTF {#3} &lt; 3
      { #1 { #2 - 1 } { #3 + 12 } {#4} }
      { #1 {#2} {#3} {#4} }
  }
\cs_new:Npn \zhnum_two_digits:n #1
  {
    \int_compare:nNnT {#1} &lt; { 10 } { 0 }
    \int_eval:n {#1}
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_Zeller_Gregorian:nnn}
% æ&nbsp;¼é‡ŒåŽ†ï¼ˆ\zhdate{1582/10/15}åŠä»¥åŽï¼‰çš„è®¡ç®—å…¬å¼
% \[
%   h = \biggl(q + \biggl\lfloor\frac{26(m+1)}{10}\biggr\rfloor + Y +
%   \biggl\lfloor\frac Y4\biggr\rfloor + 6\biggl\lfloor\frac Y{100}\biggr\rfloor
%   + \biggl\lfloor\frac Y{400}\biggr\rfloor\biggr) \pmod 7
% \]
% å…¶ä¸­ $Y$ ä¸ºå¹´ï¼Œ$m$ ä¸ºæœˆï¼Œ$q$ ä¸ºæ—¥ï¼›è‹¥ $m=1,2$ï¼Œåˆ™ä»¤ $m\mathbin{{+}{=}}12$ï¼ŒåŒæ—¶ $Y\mathop{--}{}$ã€‚
%    \begin{macrocode}
\cs_new:Npn \zhnum_Zeller_Gregorian:nnn #1#2#3
  {
    \int_mod:nn
      {
          (#3)
        + \int_div_truncate:nn { 26 * ( #2 + 1 ) } { 10 }
        + (#1)
        + \int_div_truncate:nn {#1} { 4 }
        + 6 * \int_div_truncate:nn {#1} { 100 }
        + \int_div_truncate:nn {#1} { 400 }
      }
      { 7 }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_Zeller_Julian:nnn}
% å„’ç•¥åŽ†ï¼ˆ\zhdate{1582/10/04}åŠä»¥å‰ï¼‰çš„è®¡ç®—å…¬å¼
% \[
%   h = \biggl(q + \biggl\lfloor\frac{26(m+1)}{10}\biggr\rfloor + Y +
%   \biggl\lfloor\frac Y4\biggr\rfloor + 5\biggr) \pmod 7
% \]
%    \begin{macrocode}
\cs_new:Npn \zhnum_Zeller_Julian:nnn #1#2#3
  {
    \int_mod:nn
      {
          (#3)
        + \int_div_truncate:nn { 26 * ( #2 + 1 ) } { 10 }
        + (#1)
        + \int_div_truncate:nn {#1} { 4 }
        + 5
      }
      { 7 }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhtime}
% è¾“å‡ºæ—¶é—´ã€‚
%    \begin{macrocode}
\zhnum_expand_wrap:wn
\cs_new:Npn \zhtime #1
  { \@@_time:ww #1 \q_stop }
\use:e
  {
    \cs_new:Npn \exp_not:N \@@_time:ww
      #1 \c_colon_str #2 \exp_not:N \q_stop
  }
  { \@@_time_aux:nn {#1} {#2} }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhcurrtime}
% è¾“å‡ºå½“å‰æ—¶é—´ã€‚
%    \begin{macrocode}
\zhnum_expand_wrap:wn
\cs_new:Npn \zhcurrtime
  {
    \@@_time_aux:nn
      { \int_div_truncate:nn \tex_time:D { 60 } }
      { \int_mod:nn \tex_time:D { 60 } }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_time_aux:nn,\@@_time_aux:Nnnn}
%    \begin{macrocode}
\cs_new:Npn \@@_time_aux:nn
  {
    \bool_if:NTF \l_@@_time_bool
      { \@@_time_aux:Nnnn \zhnum_int:n { } }
      { \@@_time_aux:Nnnn \int_to_arabic:n { \l_@@_arabic_sep_tl } }
  }
\cs_new:Npn \@@_time_aux:Nnnn #1#2#3#4
  {
    #1 {#3} #2 \zhnum_output:n { hour } #2
    #1 {#4} #2 \zhnum_output:n { minute }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_scale_map:n,\zhnum_scale_map_loop:n}
% å¤§æ•°ç³»ç»Ÿçš„æ˜&nbsp;å°„ã€‚
%    \begin{macrocode}
\cs_new:Npn \zhnum_scale_map:n #1
  {
    \tl_if_exist:cTF { l_@@_s #1 _tl }
      { \zhnum_output:n { s #1 } }
      { \zhnum_scale_map_hook:n {#1} }
  }
\cs_new:Npn \zhnum_scale_map_loop:n #1
  { \zhnum_scale_map:n { \int_mod:nn {#1} \l_@@_scale_int } }
\cs_generate_variant:Nn \zhnum_scale_map:n { f }
\int_new:N \l_@@_scale_int
\int_set:Nn \l_@@_scale_int { 11 }
\cs_new_eq:NN \zhnum_scale_map_hook:n \zhnum_scale_map_loop:n
\tl_new:c { l_@@_s 0 _tl }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhnumExtendScaleMap}
% æ‰©å±•è¿›ä½ç³»ç»Ÿã€‚
%    \begin{macrocode}
\NewDocumentCommand \zhnumExtendScaleMap { &gt; { \TrimSpaces } +o +m }
  {
    \int_zero:N \l_@@_tmp_int
    \clist_map_function:nN {#2} \zhnum_set_scale:n
    \tl_if_novalue:nF {#1}
      { \cs_set:Npn \zhnum_scale_map_hook:n ##1 {#1} }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_set_scale:n}
%    \begin{macrocode}
\cs_new_protected:Npn \zhnum_set_scale:n #1
  {
    \int_incr:N \l_@@_tmp_int
    \exp_args:Nc \@@_set_scale:Nn
      { l_@@_s \int_eval:n { \l_@@_tmp_int + 11 } _tl }
      {#1}
  }
\cs_new_protected:Npn \@@_set_scale:Nn #1
  {
    \tl_if_exist:NF #1
      {
        \tl_new:N #1
        \int_incr:N \l_@@_scale_int
      }
    \tl_set:Nn #1
  }
\int_new:N \l_@@_tmp_int
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_ganzhi_normal:nnn}
% ä¿è¯å¹²æ”¯çš„å‚æ•°ä¸ºæ­£æ•°ã€‚
%    \begin{macrocode}
\zhnum_expand_wrap:wn
\cs_new:Npn \zhnum_ganzhi_normal:nnn #1#2#3
  {
    \int_compare:nNnF {#1} &lt; \c_one_int
      {
        \cs_if_free:cF { l_@@_ #2 _ #1 _tl }
          { \zhnum_output:n { #2 _ #1 } }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_ganzhi_cyclic:nnn}
% \begin{macro}{\@@_ganzhi_cyclic_mod:nnnn}
% å¯¹è¶…å‡ºèŒƒå›´çš„æ•°å­—å–æ¨¡ï¼Œå‚æ•° |0| çš„ç»“æžœæ˜¯ç©ºå€¼ã€‚
%    \begin{macrocode}
\zhnum_expand_wrap:wn
\cs_new:Npn \zhnum_ganzhi_cyclic:nnn #1#2#3
  {
    \int_compare:nNnF {#1} = \c_zero_int
      {
        \tl_if_exist:cTF { l_@@_ #2 _ #1 _tl }
          { \zhnum_output:n { #2 _ #1 } }
          {
            \@@_ganzhi_cyclic_mod:fnnn
              { \int_mod:nn {#1} {#3} } {#1} {#2} {#3}
          }
      }
  }
\cs_new:Npn \@@_ganzhi_cyclic_mod:nnnn #1#2#3#4
  {
    \int_compare:nNnTF {#2} &gt; \c_zero_int
      { \zhnum_output:n { #3 _ #1 } }
      {
        \int_compare:nNnTF {#1} = \c_zero_int
          { \zhnum_output:n { #3 _ 1 } }
          { \zhnum_output:n { #3 _ \int_eval:n {  #1 + #4 + 1 } } }
      }
  }
\cs_generate_variant:Nn \@@_ganzhi_cyclic_mod:nnnn { f }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_ganzhi:nnn}
% é»˜è®¤ä¸å¯¹è¶…å‡ºèŒƒå›´çš„æ•°å­—å–æ¨¡ã€‚
%    \begin{macrocode}
\cs_new_eq:NN \zhnum_ganzhi:nnn \zhnum_ganzhi_normal:nnn
\cs_generate_variant:Nn \zhnum_ganzhi:nnn { f }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhtiangan}
% å¤©å¹²ã€‚
%    \begin{macrocode}
\cs_new:Npn \zhtiangan #1
  { \zhnum_ganzhi:fnn { \int_eval:n {#1} } { tiangan } { 10 } }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhdizhi}
% åœ°æ”¯ã€‚
%    \begin{macrocode}
\cs_new:Npn \zhdizhi #1
  { \zhnum_ganzhi:fnn { \int_eval:n {#1} } { dizhi } { 12 } }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhganzhi}
% å¹²æ”¯ã€‚
%    \begin{macrocode}
\cs_new:Npn \zhganzhi #1
  { \zhnum_ganzhi:fnn { \int_eval:n {#1} } { ganzhi } { 60 } }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhganzhinian}
% å¹²æ”¯çºªå¹´ã€‚
%    \begin{macrocode}
\cs_new:Npn \zhganzhinian #1
  { \zhnum_ganzhi_nian:f { \int_eval:n {#1} } }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_ganzhi_nian:n}
% å¹²æ”¯çºªå¹´ã€‚å…¬å…ƒå…ƒå¹´æ˜¯ |\zhganzhi{58}|ã€‚
%    \begin{macrocode}
\zhnum_expand_wrap:wn
\cs_new:Npn \zhnum_ganzhi_nian:n #1
  {
    \int_compare:nNnTF {#1} &gt; \c_zero_int
      { \zhnum_output:n { ganzhi_ \int_mod:nn { #1 + 57 } { 60 } } }
      {
        \int_compare:nNnF {#1} = \c_zero_int
          {
            \zhnum_output:n
              {
                ganzhi_ \int_eval:n
                  { \int_mod:nn { #1 - 2 } { 60 } + 60 }
              }
          }
      }
  }
\cs_generate_variant:Nn \zhnum_ganzhi_nian:n { f }
%    \end{macrocode}
% \end{macro}
%
% æ&nbsp;¹æ®éœ€è¦è®¾ç½®ä¸­æ–‡é˜¿æ‹‰ä¼¯æ•°å­—ã€‚
%    \begin{macrocode}
\tl_new:N \l_@@_kv_tl
\tl_new:N \l_@@_tmp_tl
\group_begin:
  \tl_build_begin:N \l_@@_kv_tl
  \int_step_inline:nn { 10 }
    {
      \tl_new:c { l_@@_ #1 _tl }
      \tl_build_put_right:Nx \l_@@_kv_tl
        {
            #1 .tl_set:N = \exp_not:c { l_@@_normal_    #1 _tl } ,
           F#1 .tl_set:N = \exp_not:c { l_@@_financial_ #1 _tl } ,
          E \int_eval:n { #1 * 4 }
               .tl_set:N = \exp_not:c { l_@@_ s#1 _tl } ,
        }
    }
  \clist_map_inline:nn { 0 , 100 , 1000 }
    {
      \tl_new:c { l_@@_ #1 _tl }
      \tl_build_put_right:Nx \l_@@_kv_tl
        {
           #1 .tl_set:N = \exp_not:c { l_@@_normal_    #1 _tl } ,
          F#1 .tl_set:N = \exp_not:c { l_@@_financial_ #1 _tl } ,
        }
    }
  \clist_map_inline:nn
    {
      20 , 30 , 40 , 200 ,
      dot , and , parts , year , month , day , hour , minute
    }
    {
      \tl_build_put_right:Nx \l_@@_kv_tl
        { #1 .tl_set:N = \exp_not:c { l_@@_ #1 _tl } , }
    }
  \tl_build_put_right:Nx \l_@@_kv_tl
    {
      -   .tl_set:N = \exp_not:N \l_@@_minus_tl ,
      -0  .tl_set:N = \exp_not:N \l_@@_null_tl ,
      E2  .tl_set:N = \exp_not:c { l_@@_normal_     100 _tl } ,
      E3  .tl_set:N = \exp_not:c { l_@@_normal_    1000 _tl } ,
      FE2 .tl_set:N = \exp_not:c { l_@@_financial_  100 _tl } ,
      FE3 .tl_set:N = \exp_not:c { l_@@_financial_ 1000 _tl } ,
      E44 .tl_set:N = \exp_not:c { l_@@_ s11 _tl }
    }
  \tl_build_get:NN \l_@@_kv_tl \l_@@_tmp_tl
  \cs_set:Npn \@@_tmp:w #1 . #2 \q_stop
    { , #1 .groups:n = { user } }
  \clist_map_inline:Nn \l_@@_tmp_tl
    {
      \tl_build_put_right:Nx \l_@@_kv_tl
        { \@@_tmp:w #1 \q_stop }
    }
  \tl_build_put_right:Nn \l_@@_kv_tl
    {
      ,
      weekday .tl_set:N = \l_@@_weekday_tl ,
      weekday .groups:n = { user , pre , weekday } ,
    }
  \clist_map_inline:nn
    { mon , tue , wed , thu , fri , sat , sun }
    {
      \tl_build_put_right:Nx \l_@@_kv_tl
        {
          #1 .tl_set:N = \exp_not:c { l_@@_ #1 _tl } ,
          #1 .groups:n = { user , pos , day } ,
        }
    }
  \int_step_inline:nn { 10 }
    {
      \tl_build_put_right:Nx \l_@@_kv_tl
        {
          T#1 .tl_set:N = \exp_not:c { l_@@_ganzhi_ #1 _tl } ,
          T#1 .groups:n = { user , pre , tiandi } ,
        }
    }
  \int_step_inline:nn { 12 }
    {
      \tl_build_put_right:Nx \l_@@_kv_tl
        {
          D#1 .tl_set:N = \exp_not:c { l_@@_dizhi_ #1 _tl } ,
          D#1 .groups:n = { user , pre , tiandi } ,
        }
    }
  \int_step_inline:nn { 60 }
    {
      \tl_build_put_right:Nx \l_@@_kv_tl
        {
          GZ#1 .tl_set:N = \exp_not:c { l_@@_ganzhi_ #1 _tl } ,
          GZ#1 .groups:n = { user , pos , ganzhi } ,
        }
    }
  \tl_build_end:N \l_@@_kv_tl
  \exp_args:NNno \group_end:
\keys_define:nn
  { zhnum / options }
  { \l_@@_kv_tl }
%    \end{macrocode}
%
% \begin{macro}[int]
%   {
%     \zhnum_set_digits_map:nn,
%     \zhnum_set_digits_map:nnn,
%     \zhnum_set_financial_map:nn,
%     \zhnum_set_financial_map:nnn,
%     \zhnum_set_tiangan_map:nn,
%     \zhnum_set_dizhi_map:nn
%   }
% \begin{variable}
%   {
%     \l_@@_cfg_map_prop,
%     \l_@@_cfg_map_var_prop,
%     \l_@@_cfg_map_finan_prop,
%     \l_@@_cfg_map_ganzhi_prop
%   }
% å°†é…ç½®æ–‡ä»¶ä¸­çš„ä¸­æ–‡æ•°å­—ä¿å­˜åˆ° \texttt{prop} å˜é‡ä¸­ã€‚
%    \begin{macrocode}
\cs_new_protected:Npn \zhnum_set_digits_map:nn #1
  { \prop_put:Nnn \l_@@_cfg_map_prop {#1} }
\cs_new_protected:Npn \zhnum_set_digits_map:nnn #1#2#3
  {
    \prop_put_if_new:Nnn \l_@@_cfg_map_prop {#1} {#3}
    \prop_put:Nnn \l_@@_cfg_map_var_prop {#1_#2} {#3}
  }
\cs_new_protected:Npn \zhnum_set_financial_map:nn #1
  { \prop_put:Nnn \l_@@_cfg_map_finan_prop {#1} }
\cs_new_protected:Npn \zhnum_set_financial_map:nnn #1#2#3
  {
    \prop_put_if_new:Nnn \l_@@_cfg_map_finan_prop {#1} {#3}
    \prop_put:Nnn \l_@@_cfg_map_var_prop { financial_#1_#2 } {#3}
  }
\cs_new_protected:Npn \zhnum_set_tiangan_map:nn #1
  { \prop_put:Nnn \l_@@_cfg_map_ganzhi_prop { tiangan_#1 } }
\cs_new_protected:Npn \zhnum_set_dizhi_map:nn #1
  { \prop_put:Nnn \l_@@_cfg_map_ganzhi_prop { dizhi_#1 } }
\prop_new:N \l_@@_cfg_map_prop
\prop_new:N \l_@@_cfg_map_var_prop
\prop_new:N \l_@@_cfg_map_finan_prop
\prop_new:N \l_@@_cfg_map_ganzhi_prop
%    \end{macrocode}
% \end{variable}
% \end{macro}
%
% \begin{macro}[int]
%   {
%     \zhnum_parse_config:,
%     \zhnum_check_simp:nn,
%     \zhnum_check_financial:nn,
%     \zhnum_set_week_day:
%   }
% å°† \texttt{prop} è¡¨è½¬åŒ–åˆ°å•ç‹¬çš„ \texttt{tl} å˜é‡ã€‚
%    \begin{macrocode}
\cs_new_protected:Npn \zhnum_parse_config:
  {
    \tl_clear_new:N \l_@@_reset_tl
    \tl_clear_new:N \l_@@_reset_simp_tl
    \tl_clear_new:N \l_@@_reset_trad_tl
    \tl_clear_new:N \l_@@_set_ancient_tl
    \tl_clear_new:N \l_@@_set_normal_tl
    \tl_clear_new:N \l_@@_reset_ancient_tl
    \tl_clear_new:N \l_@@_reset_normal_tl
    \tl_clear_new:N \l_@@_reset_financial_tl
    \prop_map_function:NN \l_@@_cfg_map_prop \zhnum_check_simp:nn
    \zhnum_set_ganzhi:
    \zhnum_reset_all:
  }
\cs_new_protected:Npn \zhnum_check_simp:nn #1#2
  {
    \prop_get:NnNTF \l_@@_cfg_map_var_prop
      { #1_ancient } \l_@@_ancient_tl
      { \@@_add_reset_ancient:nN {#1} \l_@@_ancient_tl }
      {
        \@@_check_simp_aux:nn {#2} {#1}
        \prop_get:NnNT \l_@@_cfg_map_finan_prop {#1} \l_@@_tmp_tl
          {
            \exp_args:No \@@_check_simp_aux:nn
              { \l_@@_tmp_tl } { financial_ #1 }
            \@@_add_reset_financial:n {#1}
          }
      }
  }
\cs_new_protected:Npn \@@_check_simp_aux:nn #1#2
  {
    \prop_get:NnNTF \l_@@_cfg_map_var_prop
      { #2 _trad } \l_@@_trad_tl
      {
        \prop_get:NnNF \l_@@_cfg_map_var_prop
          { #2 _simp } \l_@@_simp_tl
          { \tl_set:Nn \l_@@_simp_tl {#1} }
        \@@_add_reset_simp:nNN
          {#2} \l_@@_simp_tl \l_@@_trad_tl
      }
      { \@@_add_reset:nn {#2} {#1} }
  }
\tl_new:N \l_@@_simp_tl
\tl_new:N \l_@@_trad_tl
\tl_new:N \l_@@_ancient_tl
\cs_new_protected:Npn \@@_add_reset:nn #1#2
  {
    \tl_put_right:Nx \l_@@_reset_tl
      {
        \tl_set:Nn \exp_not:c { l_@@_ #1 _tl }
          { \exp_not:n {#2} }
      }
  }
\cs_new_protected:Npn \@@_add_reset_simp:nNN #1#2#3
  {
    \tl_put_right:Nx \l_@@_reset_simp_tl
      {
        \tl_set:Nn \exp_not:c { l_@@_ #1 _tl }
          { \exp_not:o {#2} }
      }
    \tl_put_right:Nx \l_@@_reset_trad_tl
      {
        \tl_set:Nn \exp_not:c { l_@@_ #1 _tl }
          { \exp_not:o {#3} }
      }
  }
\cs_new_protected:Npn \@@_add_reset_financial:n #1
  {
    \tl_put_right:Nx \l_@@_set_normal_tl
      {
        \tl_set_eq:NN
          \exp_not:c { l_@@_normal_ #1 _tl }
          \exp_not:c { l_@@_ #1 _tl }
      }
    \tl_put_right:Nx \l_@@_reset_normal_tl
      {
        \tl_set_eq:NN
          \exp_not:c { l_@@_ #1 _tl }
          \exp_not:c { l_@@_normal_ #1 _tl }
      }
    \tl_put_right:Nx \l_@@_reset_financial_tl
      {
        \tl_set_eq:NN
          \exp_not:c { l_@@_ #1 _tl }
          \exp_not:c { l_@@_financial_ #1 _tl }
      }
  }
\cs_new_protected:Npn \@@_add_reset_ancient:nN #1#2
  {
    \tl_put_right:Nx \l_@@_reset_ancient_tl
      {
        \tl_set:Nn \exp_not:c { l_@@_ #1 _tl }
          { \exp_not:o {#2} }
      }
    \tl_put_right:Nx \l_@@_set_ancient_tl
      {
        \tl_concat:NNN
          \exp_not:c { l_@@_ #1 _tl }
          \exp_not:c { l_@@_   \str_head:n {#1} _tl }
          \exp_not:c { l_@@_ 1 \str_tail:n {#1} _tl }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]
%   {
%     \zhnum_set_week_day:,
%     \zhnum_reset_week_day:
%   }
%    \begin{macrocode}
\cs_new_protected:Npn \zhnum_set_week_day:
  {
    \cs_set_protected:Npx \zhnum_reset_week_day:
      {
        \@@_set_week_day:nn { mon } { 1 }
        \@@_set_week_day:nn { tue } { 2 }
        \@@_set_week_day:nn { wed } { 3 }
        \@@_set_week_day:nn { thu } { 4 }
        \@@_set_week_day:nn { fri } { 5 }
        \@@_set_week_day:nn { sat } { 6 }
        \@@_set_week_day:nn { sun } { day }
      }
  }
\cs_new_eq:NN \zhnum_reset_week_day: \prg_do_nothing:
\cs_new:Npn \@@_set_week_day:nn #1#2
  {
    \tl_set:Nx \exp_not:c { l_@@_ #1 _tl }
      {
        \exp_not:N \exp_not:o { \exp_not:N \l_@@_weekday_tl }
        \exp_not:N \exp_not:n { \exp_not:v { l_@@_ #2 _tl } }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]
%   {
%     \zhnum_set_ganzhi:,
%     \zhnum_reset_ganzhi:
%   }
%    \begin{macrocode}
\cs_new_protected:Npn \zhnum_set_ganzhi:
  {
    \prop_map_function:NN
      \l_@@_cfg_map_ganzhi_prop
      \@@_add_reset:nn
  }
\cs_new_protected:Npn \@@_reset_ganzhi:nn #1#2
  { \tl_set:cn { l_@@_ #1 _tl } {#2} }
\cs_new:Npn \zhnum_zero_mod:nn #1#2
  { \exp_args:Nf \@@_zero_mod_aux:nn { \int_mod:nn {#1} {#2} } {#2} }
\cs_new:Npn \@@_zero_mod_aux:nn #1#2
  { \int_compare:nNnTF {#1} = \c_zero_int {#2} {#1} }
\tl_new:c { l_@@_dizhi_ 0 _tl }
\tl_new:c { l_@@_ganzhi_ 0 _tl }
\tl_new:c { l_@@_tiangan_ 0 _tl }
\group_begin:
\cs_set:Npn \@@_tmp:w #1
  {
    \tl_concat:NNN
      \exp_not:c { l_@@_ganzhi_ #1 _tl }
      \exp_not:c { l_@@_tiangan_ \zhnum_zero_mod:nn {#1} { 10 } _tl }
      \exp_not:c { l_@@_dizhi_   \zhnum_zero_mod:nn {#1} { 12 } _tl }
  }
\cs_new_protected:Npx \zhnum_reset_ganzhi:
  {
    \tl_set_eq:NN
      \exp_not:c { l_@@_dizhi_ 0 _tl }
      \exp_not:c { l_@@_dizhi_ 12 _tl }
    \tl_set_eq:NN
      \exp_not:c { l_@@_tiangan_ 0 _tl }
      \exp_not:c { l_@@_tiangan_ 10 _tl }
    \int_step_function:nN { 60 } \@@_tmp:w
    \tl_set_eq:NN
      \exp_not:c { l_@@_ganzhi_ 0 _tl }
      \exp_not:c { l_@@_ganzhi_ 60 _tl }
  }
\group_end:
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]
%   {
%     \zhnum_reset_config:,
%     \zhnum_reset_all:,
%     \zhnum_reset_style:
%   }
%    \begin{macrocode}
\cs_new_protected:Npn \zhnum_reset_config:
  { \zhnum_load_cfg:o { \l_@@_encoding_str } }
\cs_new_protected:Npn \zhnum_reset_all:
  {
    \zhnum_reset_main:
    \zhnum_reset_simp:
    \zhnum_set_week_day:
    \zhnum_reset_week_day:
    \zhnum_reset_ganzhi:
    \zhnum_reset_normal:
  }
\cs_new_protected:Npn \zhnum_reset_main:
  {
    \tl_use:N \l_@@_reset_tl
    \tl_use:N \l_@@_set_normal_tl
    \tl_concat:NNN
      \l_@@_reset_normal_tl
      \l_@@_reset_normal_tl
      \c_@@_set_zero_tl
    \tl_concat:NNN
      \l_@@_reset_financial_tl
      \l_@@_reset_financial_tl
      \c_@@_set_zero_tl
    \tl_concat:NNN
      \l_@@_reset_financial_tl
      \l_@@_reset_financial_tl
      \l_@@_set_ancient_tl
  }
\tl_const:Nx \c_@@_set_zero_tl
  {
    \tl_set_eq:NN
      \exp_not:N \l_@@_zero_tl
      \exp_not:c { l_@@_0_tl }
  }
\tl_new:N \l_@@_zero_tl
\cs_new_protected:Npn \zhnum_reset_style:
  {
    \zhnum_reset_simp:
    \zhnum_reset_normal:
  }
\cs_new_protected:Npn \zhnum_reset_simp:
  {
    \bool_if:NTF \l_@@_simp_bool
      { \tl_use:N \l_@@_reset_simp_tl }
      { \tl_use:N \l_@@_reset_trad_tl }
  }
\cs_new_protected:Npn \zhnum_reset_normal:
  {
    \bool_if:NTF \l_@@_normal_bool
      {
        \tl_use:N \l_@@_reset_normal_tl
        \@@_reset_ancient:
        \@@_reset_zero:
      }
      { \tl_use:N \l_@@_reset_financial_tl }
  }
\cs_new_protected:Npn \@@_reset_ancient:
  {
    \bool_if:NTF \l_@@_ancient_bool
      { \tl_use:N \l_@@_reset_ancient_tl }
      { \tl_use:N \l_@@_set_ancient_tl }
  }
\cs_new_protected:Npx \@@_reset_zero:
  {
    \exp_not:n { \bool_if:NT \l_@@_null_bool }
      {
        \tl_set_eq:NN
          \exp_not:c { l_@@_0_tl }
          \exp_not:N \l_@@_null_tl
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_load_cfg:n}
% æ&nbsp;¹æ®é€‰å®šç¼–ç&nbsp;è½½å…¥é…ç½®æ–‡ä»¶ã€‚
%    \begin{macrocode}
\cs_new_protected:Npn \zhnum_load_cfg:n #1
  {
    \zhnum_set_cfg_name:Nn \l_@@_cfg_str {#1}
    \str_if_eq:NNTF \l_@@_cfg_str \l_@@_last_cfg_str
      { \zhnum_reset_all: }
      {
        \zhnum_update_cfg:n {#1}
        \zhnum_parse_config:
      }
  }
\cs_generate_variant:Nn \zhnum_load_cfg:n { o }
\cs_new_protected:Npn \zhnum_update_cfg:n #1
  {
    \prop_if_exist:cTF { g_@@_cfg_ \l_@@_cfg_str _prop }
      { \@@_set_cfg_prop: }
      { \zhnum_input_cfg:n {#1} }
  }
\cs_new_protected:Npn \@@_set_cfg_prop:
  {
    \str_set_eq:NN \l_@@_last_cfg_str \l_@@_cfg_str
    \@@_update_cfg_prop:N \prop_set_eq:Nc
  }
\cs_new_protected:Npn \zhnum_input_cfg:n #1
  {
    \file_get_full_name:nNTF { zhnumber - #1 .cfg } \l_@@_cfg_file_tl
      {
        \bool_set_false:N \l_@@_reset_bool
        \@@_update_cfg_prop:N \@@_prop_initial:Nn
        \group_begin:
          \zhnum_set_catcode:
          \exp_args:No \file_input:n { \l_@@_cfg_file_tl }
          \@@_update_cfg_prop:N \@@_prop_gset_eq:Nn
        \group_end:
        \@@_set_cfg_prop:
      }
      { \msg_error:nnx { zhnumber } { file-not-found } {#1} }
  }
\tl_new:N \l_@@_cfg_file_tl
\cs_new_protected:Npn \@@_update_cfg_prop:N
  { \exp_args:No \@@_update_cfg_prop_aux:nN { \l_@@_cfg_str } }
\cs_new_protected:Npn \@@_update_cfg_prop_aux:nN #1#2
  {
    #2 \l_@@_cfg_map_prop        { g_@@_cfg_        #1 _prop }
    #2 \l_@@_cfg_map_var_prop    { g_@@_cfg_var_    #1 _prop }
    #2 \l_@@_cfg_map_finan_prop  { g_@@_cfg_finan_  #1 _prop }
    #2 \l_@@_cfg_map_ganzhi_prop { g_@@_cfg_ganzhi_ #1 _prop }
  }
\cs_new_protected:Npn \@@_prop_initial:Nn #1#2
  {
    \prop_clear:N #1
    \prop_new:c {#2}
  }
\cs_new_protected:Npn \@@_prop_gset_eq:Nn #1#2
  { \prop_gset_eq:cN {#2} #1 }
\str_new:N \l_@@_cfg_str
\str_new:N \l_@@_last_cfg_str
\bool_new:N \l_@@_reset_bool
\msg_new:nnnn  { zhnumber } { file-not-found }
  { File~`#1'~not~found. }
  {
    The~requested~file~could~not~be~found~in~the~current~directory,~
    in~the~TeX~search~path~or~in~the~LaTeX~search~path.
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\c_@@_unicode_engine_bool}
% ä½¿ç”¨ \upTeX{} çš„æ—¶å€™ï¼Œä¹Ÿä¸å¿…å°†æ±‰å­—çš„é¦–å­—ç¬¦è®¾ç½®ä¸ºæ´»åŠ¨å­—ç¬¦ã€‚åˆ¤æ–­ |^^^^0021| æ˜¯å¦ä¸º
% å•ä¸ªè®°å·çš„åŠžæ³•å¯¹ \upTeX{} ä¸é€‚ç”¨ã€‚
%    \begin{macrocode}
\bool_const:Nn \c_@@_unicode_engine_bool
  {
    \bool_lazy_any_p:n
      {
        { \sys_if_engine_xetex_p:  }
        { \sys_if_engine_luatex_p: }
        { \sys_if_engine_uptex_p: }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]
%   {
%     \zhnum_set_catcode:,
%     \zhnum_set_cfg_name:Nn,
%     \zhnum_reset_config:
%   }
% è®¾ç½®ä¸Žæ¢å¤é…ç½®æ–‡ä»¶å‰åŽçš„ catcodeã€‚\pdfLaTeX{} éœ€è¦å°†æ±‰å­—çš„é¦–å­—èŠ‚è®¾ç½®ä¸ºæ´»åŠ¨å­—ç¬¦ã€‚
%    \begin{macrocode}
\bool_if:NTF \c_@@_unicode_engine_bool
  {
    \cs_new_eq:NN \zhnum_set_catcode: \prg_do_nothing:
    \cs_new_protected:Npn \zhnum_set_cfg_name:Nn #1#2
      {
        \str_set:Nx \l_@@_encoding_str {#2}
        \str_set_eq:NN #1 \l_@@_encoding_str
      }
  }
  {
    \cs_new_protected:Npn \zhnum_set_catcode:
      {
        \bool_if:NTF \l_@@_active_char_bool
          { \zhnum_set_active: }
          { \zhnum_set_other: }
      }
    \cs_new_protected:Npx \zhnum_set_active:
      {
        \int_step_function:nnN
          { 128 } { 255 } \char_set_catcode_active:n
      }
    \cs_new_protected:Npx \zhnum_set_other:
      {
        \int_step_function:nnN
          { 128 } { 255 } \char_set_catcode_other:n
      }
    \cs_new_protected:Npn \zhnum_set_cfg_name:Nn #1#2
      {
        \str_set:Nx \l_@@_encoding_str {#2}
        \str_set:Nx #1
          {
            \l_@@_encoding_str
            \bool_if:NTF \l_@@_active_char_bool
              { / active }
              { / other }
          }
      }
    \bool_new:N \l_@@_active_char_bool
    \bool_set_true:N \l_@@_active_char_bool
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\zhnum_set_encoding:n}
% è®¾ç½®ç¼–ç&nbsp;ã€‚
%    \begin{macrocode}
\cs_new_protected:Npn \zhnum_set_encoding:n #1
  {
    \str_set:Nx \l_@@_encoding_str
      { \str_lowercase:n {#1} }
    \zhnum_load_cfg:o { \l_@@_encoding_str }
  }
\str_new:N \l_@@_encoding_str
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{encoding,style,null,reset}
% å®åŒ…è®¾ç½®é€‰é¡¹ã€‚
%    \begin{macrocode}
\keys_define:nn { zhnum / options }
  {
    encoding         .choices:nn =
      { UTF8 , GBK , Big5 }
      { \exp_args:No \zhnum_set_encoding:n { \l_keys_choice_tl } } ,
    encoding          .default:n = { GBK } ,
    encoding / Bg5       .meta:n = { encoding = Big5 } ,
    encoding / unknown   .code:n =
      { \msg_error:nnn { zhnumber } { encoding-invalid } {#1} } ,
    style .multichoice: ,
    style / Normal       .code:n =
      {
        \bool_set_false:N \l_@@_ancient_bool
        \bool_set_true:N  \l_@@_normal_bool
      } ,
    style / Financial    .code:n =
      {
        \bool_set_false:N \l_@@_ancient_bool
        \bool_set_false:N \l_@@_normal_bool
      } ,
    style / Ancient      .code:n =
      {
        \bool_set_true:N \l_@@_ancient_bool
        \bool_set_true:N \l_@@_normal_bool
      } ,
    style / Simplified   .code:n = { \bool_set_true:N  \l_@@_simp_bool } ,
    style / Traditional  .code:n = { \bool_set_false:N \l_@@_simp_bool } ,
    style             .default:n = { Normal , Simplified } ,
    style              .groups:n = { style } ,
    null             .bool_set:N = \l_@@_null_bool ,
    null               .groups:n = { style } ,
    time .choice: ,
    time / Chinese       .code:n = { \bool_set_true:N \l_@@_time_bool } ,
    time / Arabic        .code:n = { \bool_set_false:N  \l_@@_time_bool } ,
    time              .default:n = { Arabic } ,
    reset            .bool_set:N = \l_@@_reset_bool ,
    activechar       .bool_set:N = \l_@@_active_char_bool ,
    ganzhi-cyclic .choice: ,
    ganzhi-cyclic / true .code:n =
      { \cs_set_eq:NN \zhnum_ganzhi:nnn \zhnum_ganzhi_cyclic:nnn } ,
    ganzhi-cyclic / false.code:n =
      { \cs_set_eq:NN \zhnum_ganzhi:nnn \zhnum_ganzhi_normal:nnn } ,
    ganzhi-cyclic     .default:n = { true } ,
    arabicsep          .tl_set:N = \l_@@_arabic_sep_tl
  }
\bool_new:N \l_@@_simp_bool
\bool_new:N \l_@@_normal_bool
\bool_new:N \l_@@_ancient_bool
\msg_new:nnnn { zhnumber } { encoding-invalid }
  { The~encoding~`#1'~is~invalid. }
  { Available~encodings~are~`UTF8',~`GBK'~and~`Big5'. }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\zhnumsetup}
% åœ¨æ–‡æ¡£ä¸­è®¾ç½® \pkg{zhnumber} çš„æŽ¥å£ã€‚
%    \begin{macrocode}
\NewDocumentCommand \zhnumsetup { +m }
  {
    \zhnum_set:n {#1}
    \tex_ignorespaces:D
  }
\cs_new_protected:Npn \zhnum_set:n #1
  {
    \bool_set_false:N \l_@@_reset_bool
    \keys_set_filter:nnnN { zhnum / options }
      { style , user } {#1} \l_@@_kv_tl
    \tl_if_empty:NF \l_@@_kv_tl
      { \@@_set_style: }
    \bool_if:NT \l_@@_reset_bool
      { \zhnum_reset_config: }
  }
\cs_new_protected:Npn \@@_set_style:
  {
    \keys_set_filter:nnoN { zhnum / options }
      { user } { \l_@@_kv_tl } \l_@@_tmp_tl
    \tl_if_empty:NTF \l_@@_tmp_tl
      { \zhnum_reset_style: }
      {
        \tl_if_eq:NNF \l_@@_tmp_tl \l_@@_kv_tl
          { \zhnum_reset_style: }
        \bool_if:NF \l_@@_reset_bool
          { \@@_set_user: }
      }
  }
\cs_new_protected:Npn \@@_set_user:
  {
    \keys_set_filter:nnoN { zhnum / options }
      { pre , pos } { \l_@@_tmp_tl } \l_@@_kv_tl
    \tl_if_eq:NNF \l_@@_kv_tl \l_@@_tmp_tl
      { \zhnum_reset_normal: }
    \tl_if_empty:NF \l_@@_kv_tl
      { \@@_set_pre_pos: }
  }
\cs_new_protected:Npn \@@_set_pre_pos:
  {
    \keys_set_filter:nnoN { zhnum / options }
      { pos } { \l_@@_kv_tl } \l_@@_tmp_tl
    \tl_if_eq:NNF \l_@@_tmp_tl \l_@@_kv_tl
      {
        \zhnum_reset_week_day:
        \zhnum_reset_ganzhi:
      }
    \tl_if_empty:NF \l_@@_kv_tl
      { \keys_set:no { zhnum / options } { \l_@@_kv_tl } }
  }
\cs_generate_variant:Nn \keys_set_filter:nnnN { nno }
%    \end{macrocode}
% \end{macro}
%
% åˆå§‹åŒ–è®¾ç½®å’Œæ‰§è¡Œå®åŒ…é€‰é¡¹ã€‚
%    \begin{macrocode}
\keys_set:nn { zhnum / options }
  { style , time , arabicsep = { ~ } }
\cs_if_exist:NTF \ProcessKeyOptions
  { \ProcessKeyOptions [ zhnum / options ] }
  {
    \RequirePackage { l3keys2e }
    \ProcessKeysOptions { zhnum / options }
  }
%    \end{macrocode}
%
% å¦‚æžœæ²¡æœ‰é€‰å®šç¼–ç&nbsp;ï¼Œåˆ™é€‰ç”¨ |UTF8|ã€‚
%    \begin{macrocode}
\str_if_empty:NTF \l_@@_encoding_str
  { \zhnum_set_encoding:n { UTF8 } }
  { \zhnum_reset_style: }
%    \end{macrocode}
%
%    \begin{macrocode}
%&lt;/package&gt;
%    \end{macrocode}
%
% \section{ä¸­æ–‡æ•°å­—é…ç½®æ–‡ä»¶}
% \label{sec:zhnum-map}
%
%    \begin{macrocode}
%&lt;*config&gt;
%    \end{macrocode}
%
%    \begin{macrocode}
%&lt;*!big5&gt;
\zhnum_set_digits_map:nnn { minus } { simp } { è´Ÿ }
\zhnum_set_digits_map:nnn { minus } { trad } { è²&nbsp; }
%&lt;/!big5&gt;
%&lt;*big5&gt;
\zhnum_set_digits_map:nn { minus } { è²&nbsp; }
%&lt;/big5&gt;
\zhnum_set_digits_map:nn { 0 }     { é›¶ }
%&lt;*!big5&gt;
\zhnum_set_digits_map:nn { null }  { ã€‡ }
%&lt;/!big5&gt;
%&lt;*big5&gt;
\zhnum_set_digits_map:nn { null }  { â—‹ }
%&lt;/big5&gt;
\zhnum_set_digits_map:nn { 1 }     { ä¸€ }
\zhnum_set_digits_map:nn { 2 }     { äºŒ }
\zhnum_set_digits_map:nn { 3 }     { ä¸‰ }
\zhnum_set_digits_map:nn { 4 }     { å›› }
\zhnum_set_digits_map:nn { 5 }     { äº” }
\zhnum_set_digits_map:nn { 6 }     { å…­ }
\zhnum_set_digits_map:nn { 7 }     { ä¸ƒ }
\zhnum_set_digits_map:nn { 8 }     { å…« }
\zhnum_set_digits_map:nn { 9 }     { ä¹ }
\zhnum_set_digits_map:nn { 10 }    { å }
\zhnum_set_digits_map:nn { 100 }   { ç™¾ }
\zhnum_set_digits_map:nn { 1000 }  { åƒ }
\zhnum_set_digits_map:nnn { 20 }   { ancient } { å»¿ }
\zhnum_set_digits_map:nnn { 30 }   { ancient } { å… }
\zhnum_set_digits_map:nnn { 40 }   { ancient } { åŒ }
\zhnum_set_digits_map:nnn { 200 }  { ancient } { çš• }
%&lt;*!big5&gt;
\zhnum_set_digits_map:nnn { dot } { simp } { ç‚¹ }
\zhnum_set_digits_map:nnn { dot } { trad } { é»ž }
%&lt;/!big5&gt;
%&lt;*big5&gt;
\zhnum_set_digits_map:nn { dot }   { é»ž }
%&lt;/big5&gt;
\zhnum_set_digits_map:nn { and }   { åˆ }
\zhnum_set_digits_map:nn { parts } { åˆ†ä¹‹ }
%&lt;*!big5&gt;
\zhnum_set_digits_map:nnn { s1 }    { simp } { ä¸‡ }
\zhnum_set_digits_map:nnn { s1 }    { trad } { è¬ }
\zhnum_set_digits_map:nnn { s2 }    { simp } { äº¿ }
\zhnum_set_digits_map:nnn { s2 }    { trad } { å„„ }
%&lt;/!big5&gt;
%&lt;*big5&gt;
\zhnum_set_digits_map:nn { s1 }    { è¬ }
\zhnum_set_digits_map:nn { s2 }    { å„„ }
%&lt;/big5&gt;
\zhnum_set_digits_map:nn { s3 }    { å…† }
\zhnum_set_digits_map:nn { s4 }    { äº¬ }
\zhnum_set_digits_map:nn { s5 }    { åž“ }
\zhnum_set_digits_map:nn { s6 }    { ç§­ }
\zhnum_set_digits_map:nn { s7 }    { ç©° }
%&lt;*!big5&gt;
\zhnum_set_digits_map:nnn { s8 }    { simp } { æ²Ÿ }
\zhnum_set_digits_map:nnn { s8 }    { trad } { æº }
\zhnum_set_digits_map:nnn { s9 }    { simp } { æ¶§ }
\zhnum_set_digits_map:nnn { s9 }    { trad } { æ¾— }
%&lt;/!big5&gt;
%&lt;*big5&gt;
\zhnum_set_digits_map:nn { s8 }    { æº }
\zhnum_set_digits_map:nn { s9 }    { æ¾— }
%&lt;/big5&gt;
\zhnum_set_digits_map:nn { s10 }   { æ­£ }
%&lt;*!big5&gt;
\zhnum_set_digits_map:nnn { s11 }   { simp } { è½½ }
\zhnum_set_digits_map:nnn { s11 }   { trad } { è¼‰ }
%&lt;/!big5&gt;
%&lt;*big5&gt;
\zhnum_set_digits_map:nn { s11 }   { è¼‰ }
%&lt;/big5&gt;
\zhnum_set_digits_map:nn { year }  { å¹´ }
\zhnum_set_digits_map:nn { month } { æœˆ }
\zhnum_set_digits_map:nn { day }   { æ—¥ }
%&lt;*!big5&gt;
\zhnum_set_digits_map:nnn { hour }  { simp } { æ—¶ }
\zhnum_set_digits_map:nnn { hour }  { trad } { æ™‚ }
%&lt;/!big5&gt;
%&lt;*big5&gt;
\zhnum_set_digits_map:nn { hour }  { æ™‚ }
%&lt;/big5&gt;
\zhnum_set_digits_map:nn { minute }  { åˆ† }
\zhnum_set_digits_map:nn { weekday } { æ˜ŸæœŸ }
\zhnum_set_financial_map:nn { null } { é›¶ }
\zhnum_set_financial_map:nn { 0 }    { é›¶ }
\zhnum_set_financial_map:nn { 1 }    { å£¹ }
%&lt;*!big5&gt;
\zhnum_set_financial_map:nnn { 2 }  { simp } { è´° }
\zhnum_set_financial_map:nnn { 2 }  { trad } { è²³ }
\zhnum_set_financial_map:nnn { 3 }  { simp } { å }
\zhnum_set_financial_map:nnn { 3 }  { trad } { å„ }
%&lt;/!big5&gt;
%&lt;*big5&gt;
\zhnum_set_financial_map:nn { 2 }    { è²³ }
\zhnum_set_financial_map:nn { 3 }    { åƒ }
%&lt;/big5&gt;
\zhnum_set_financial_map:nn { 4 }    { è‚† }
\zhnum_set_financial_map:nn { 5 }    { ä¼ }
%&lt;*!big5&gt;
\zhnum_set_financial_map:nnn { 6 }  { simp } { é™† }
\zhnum_set_financial_map:nnn { 6 }  { trad } { é™¸ }
%&lt;/!big5&gt;
%&lt;*big5&gt;
\zhnum_set_financial_map:nn { 6 }    { é™¸ }
%&lt;/big5&gt;
\zhnum_set_financial_map:nn { 7 }    { æŸ’ }
\zhnum_set_financial_map:nn { 8 }    { æŒ }
\zhnum_set_financial_map:nn { 9 }    { çŽ– }
\zhnum_set_financial_map:nn { 10 }   { æ‹¾ }
\zhnum_set_financial_map:nn { 100 }  { ä½° }
\zhnum_set_financial_map:nn { 1000 } { ä»Ÿ }
\zhnum_set_tiangan_map:nn { 1 }  { ç”² }
\zhnum_set_tiangan_map:nn { 2 }  { ä¹™ }
\zhnum_set_tiangan_map:nn { 3 }  { ä¸™ }
\zhnum_set_tiangan_map:nn { 4 }  { ä¸ }
\zhnum_set_tiangan_map:nn { 5 }  { æˆŠ }
\zhnum_set_tiangan_map:nn { 6 }  { å·± }
\zhnum_set_tiangan_map:nn { 7 }  { åºš }
\zhnum_set_tiangan_map:nn { 8 }  { è¾› }
\zhnum_set_tiangan_map:nn { 9 }  { å£¬ }
\zhnum_set_tiangan_map:nn { 10 } { ç™¸ }
\zhnum_set_dizhi_map:nn { 1 }  { å­ }
\zhnum_set_dizhi_map:nn { 2 }  { ä¸‘ }
\zhnum_set_dizhi_map:nn { 3 }  { å¯… }
\zhnum_set_dizhi_map:nn { 4 }  { å¯ }
\zhnum_set_dizhi_map:nn { 5 }  { è¾° }
\zhnum_set_dizhi_map:nn { 6 }  { å·³ }
\zhnum_set_dizhi_map:nn { 7 }  { åˆ }
\zhnum_set_dizhi_map:nn { 8 }  { æœª }
\zhnum_set_dizhi_map:nn { 9 }  { ç”³ }
\zhnum_set_dizhi_map:nn { 10 } { é…‰ }
\zhnum_set_dizhi_map:nn { 11 } { æˆŒ }
\zhnum_set_dizhi_map:nn { 12 } { äº¥ }
%    \end{macrocode}
%
%    \begin{macrocode}
%&lt;/config&gt;
%    \end{macrocode}
%
% \end{implementation}
%
% \Finale
%
\endinput
</pre></body></html>