diff options
Diffstat (limited to 'macros/latex/contrib/l3kernel/l3token.dtx')
-rw-r--r-- | macros/latex/contrib/l3kernel/l3token.dtx | 113 |
1 files changed, 95 insertions, 18 deletions
diff --git a/macros/latex/contrib/l3kernel/l3token.dtx b/macros/latex/contrib/l3kernel/l3token.dtx index 5583b55eef..eb2ef81b19 100644 --- a/macros/latex/contrib/l3kernel/l3token.dtx +++ b/macros/latex/contrib/l3kernel/l3token.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2022-08-23} +% \date{Released 2022-08-30} % % \maketitle % @@ -1795,36 +1795,113 @@ % \end{macro} % % \begin{macro}[rEXP]{\char_to_nfd:N} -% \begin{macro}[rEXP]{\@@_to_nfd:n} +% \begin{macro}[rEXP]{\@@_to_nfd:n, \@@_to_nfd:e} % \begin{macro}[rEXP]{\@@_to_nfd:Nw} -% Look up any \textsc{nfd} and recursively produce the result. -% \begin{macrocode} -\cs_new:Npn \char_to_nfd:N #1 +% \begin{macro}[rEXP]{\char_to_nfd:n} +% \begin{macro}[rEXP]{\char_to_nfd:w} +% \begin{macro}[rEXP]{\char_nfd_generate:n} +% \begin{macro}[rEXP]{\char_nfd_generate:nnnn} +% Look up any \textsc{nfd} and recursively produce the result. Having shared +% code between Unicode and $8$-bit engines would be ideal, but this would be +% awkward as we have completely different treatment of catcodes, numbers +% of tokens, etc. The apparent saving becomes more of a headache than it's +% worth \dots +% \begin{macrocode} +\bool_lazy_or:nnTF + { \sys_if_engine_luatex_p: } + { \sys_if_engine_xetex_p: } { - \cs_if_exist:cTF { c_@@_nfd_ \token_to_str:N #1 _ tl } + \cs_new:Npn \char_to_nfd:N #1 { - \exp_after:wN \exp_after:wN \exp_after:wN \@@_to_nfd:Nw - \exp_after:wN \exp_after:wN \exp_after:wN #1 - \cs:w c_@@_nfd_ \token_to_str:N #1 _ tl \cs_end: - \s_@@_stop + \cs_if_exist:cTF { c_@@_nfd_ \token_to_str:N #1 _ tl } + { + \exp_after:wN \exp_after:wN \exp_after:wN \@@_to_nfd:Nw + \exp_after:wN \exp_after:wN \exp_after:wN #1 + \cs:w c_@@_nfd_ \token_to_str:N #1 _tl \cs_end: + \s_@@_stop + } + { \exp_not:n {#1} } + } + \cs_new_eq:NN \@@_to_nfd:n \char_to_nfd:N + \cs_generate_variant:Nn \@@_to_nfd:n { e } + \cs_new:Npn \@@_to_nfd:Nw #1#2#3 \s_@@_stop + { + \@@_to_nfd:e + { \char_generate:nn { `#2 } { \@@_change_case_catcode:N #1 } } + \tl_if_blank:nF {#3} + { + \@@_to_nfd:e + { \char_generate:nn { `#3 } { \char_value_catcode:n { `#3 } } } + } + } + \cs_new:Npn \char_to_nfd:n #1 + { + \@@_to_nfd:e { \char_generate:nn {#1} { \char_value_catcode:n {#1} } } } - { \exp_not:n {#1} } } -\cs_set_eq:NN \@@_to_nfd:n \char_to_nfd:N -\cs_new:Npn \@@_to_nfd:Nw #1#2#3 \s_@@_stop { - \exp_args:Ne \@@_to_nfd:n - { \char_generate:nn { `#2 } { \@@_change_case_catcode:N #1 } } - \tl_if_blank:nF {#3} + \cs_new:Npn \char_to_nfd:N #1 { \exp_not:n {#1} } + \cs_new:Npn \char_to_nfd:n #1 + { + \int_compare:nNnTF {#1} > { "80 } + { \exp_args:Ne \@@_to_nfd:n { \@@_nfd_generate:n {#1} } } + { \@@_nfd_generate:n {#1} } + } + \cs_new:Npn \@@_to_nfd:n #1 { - \exp_args:Ne \@@_to_nfd:n - { \char_generate:nn { `#3 } { \char_value_catcode:n { `#3 } } } + \cs_if_exist:cTF { c_@@_nfd_ \tl_to_str:n {#1} _ tl } + { + \exp_after:wN \exp_after:wN \exp_after:wN \@@_to_nfd:w + \cs:w c_@@_nfd_ \tl_to_str:n {#1} _tl \cs_end: + \s_@@_stop + } + { \exp_not:n {#1} } + } + \cs_new:Npn \@@_to_nfd:w #1#2 \s_@@_stop + { + \@@_to_nfd:n {#1} + \tl_if_blank:nF {#2} + { \@@_to_nfd:n {#2} } } + \cs_new:Npn \@@_nfd_generate:n #1 + { + \use:e + { + \exp_not:N \@@_nfd_generate:nnnn + \char_to_utfviii_bytes:n {#1} + } + } + \cs_new:Npn \@@_nfd_generate:nnnn #1#2#3#4 + { + \tl_if_blank:nTF {#2} + { \char_generate:nn {#1} { \char_value_catcode:n {#1} } } + { + \exp_after:wN \exp_after:wN \exp_after:wN + \exp_not:N \char_generate:nn {#1} { 13 } + \exp_after:wN \exp_after:wN \exp_after:wN + \exp_not:N \char_generate:nn {#2} { 13 } + \tl_if_blank:nF {#3} + { + \exp_after:wN \exp_after:wN \exp_after:wN + \exp_not:N \char_generate:nn {#3} { 13 } + \tl_if_blank:nF {#4} + { + \exp_after:wN \exp_after:wN \exp_after:wN + \exp_not:N \char_generate:nn {#4} { 13 } + } + } + } + + } } % \end{macrocode} % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} % % \begin{macro}[EXP] % { |