diff options
Diffstat (limited to 'macros/latex/contrib/l3kernel/l3str.dtx')
-rw-r--r-- | macros/latex/contrib/l3kernel/l3str.dtx | 217 |
1 files changed, 108 insertions, 109 deletions
diff --git a/macros/latex/contrib/l3kernel/l3str.dtx b/macros/latex/contrib/l3kernel/l3str.dtx index 4b240c2aa3..3e8882fb3c 100644 --- a/macros/latex/contrib/l3kernel/l3str.dtx +++ b/macros/latex/contrib/l3kernel/l3str.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2022-11-02} +% \date{Released 2022-12-17} % % \maketitle % @@ -744,7 +744,7 @@ % % These functions should \emph{not} be used for % \begin{itemize} -% \item Caseless comparisons: use \cs{str_foldcase:n} for this +% \item Caseless comparisons: use \cs{str_casefold:n} for this % situation (case folding is distinct from lower casing). % \item Case changing text for typesetting: see the % \cs[index=text_lowercase:n]{text_lowercase:n(n)}, @@ -755,10 +755,10 @@ % \end{itemize} % \end{function} % -% \begin{function}[EXP, added = 2019-11-26] -% {\str_foldcase:n, \str_foldcase:V} +% \begin{function}[EXP, added = 2022-10-16] +% {\str_casefold:n, \str_casefold:V} % \begin{syntax} -% \cs{str_foldcase:n} \Arg{tokens} +% \cs{str_casefold:n} \Arg{tokens} % \end{syntax} % Converts the input \meta{tokens} to their string representation, as % described for \cs{tl_to_str:n}, and then folds the case of the resulting @@ -766,7 +766,7 @@ % left in the input stream. % % String folding is a process used for material such as identifiers rather -% than for \enquote{text}. The folding provided by \cs{str_foldcase:n} +% than for \enquote{text}. The folding provided by \cs{str_casefold:n} % follows the mappings provided by the \href{http://www.unicode.org}^^A % {Unicode Consortium}, who % \href{http://www.unicode.org/faq/casemap_charprop.html#2}{state}: @@ -779,7 +779,7 @@ % should be used solely for internal processing and generally should not be % stored or displayed to the end user. % \end{quote} -% The folding approach implemented by \cs{str_foldcase:n} follows the +% The folding approach implemented by \cs{str_casefold:n} follows the % \enquote{full} scheme defined by the Unicode Consortium % (\emph{e.g.}~\SS folds to \texttt{SS}). As case-folding is % a language-insensitive process, there is no special treatment of @@ -843,6 +843,16 @@ % code and so should only be used for short-term storage. % \end{variable} % +% \section{Deprecated functions} +% +% \begin{function}[EXP, added = 2019-11-26] +% {\str_foldcase:n, \str_foldcase:V} +% \begin{syntax} +% \cs{str_foldcase:n} \Arg{tokens} +% \end{syntax} +% A previous name for the functionally-identical \cs{str_casefold:n}. +% \end{function} +% % \end{documentation} % % \begin{implementation} @@ -1896,7 +1906,7 @@ % % \begin{macro}[EXP] % { -% \str_foldcase:n, \str_foldcase:V, +% \str_casefold:n, \str_casefold:V, % \str_lowercase:n, \str_lowercase:f, % \str_uppercase:n, \str_uppercase:f % } @@ -1907,27 +1917,23 @@ % \begin{macro}[EXP]{\@@_change_case_end:nw} % \begin{macro}[EXP]{\@@_change_case_loop:nw} % \begin{macro}[EXP]{\@@_change_case_space:n} -% \begin{macro}[EXP]{\@@_change_case_char:nN} -% \begin{macro}[EXP]{\@@_change_case_char_UTFviii:nNN} -% \begin{macro}[EXP]{\@@_change_case_char_UTFviii:nNNN} -% \begin{macro}[EXP]{\@@_change_case_char_UTFviii:nNNNN} -% \begin{macro}[EXP] -% { -% \@@_change_case_char_UTFviii:nn , -% \@@_change_case_char_UTFviii_lower:nn , -% \@@_change_case_char_UTFviii_upper:nn , -% \@@_change_case_char_UTFviii_fold:nn -% } +% \begin{macro}[EXP]{\@@_change_case_char:nN, \@@_change_case_char_aux:nN} +% \begin{macro}[EXP]{\@@_change_case_codepoint:nN} +% \begin{macro}[EXP]{\@@_change_case_codepoint:nNN} +% \begin{macro}[EXP]{\@@_change_case_codepoint:nNNN} +% \begin{macro}[EXP]{\@@_change_case_codepoint:nNNNN} +% \begin{macro}[EXP]{\@@_change_case_char:nnn, \@@_change_case_char_aux:nnn} +% \begin{macro}[EXP]{\@@_change_case_char:nnnnn} % Case changing for programmatic reasons is done by first detokenizing % input then doing a simple loop that only has to worry about spaces % and everything else. The output is detokenized to allow data sharing % with text-based case changing. Similarly, for $8$-bit engines the % multi-byte information is shared. % \begin{macrocode} -\cs_new:Npn \str_foldcase:n #1 { \@@_change_case:nn {#1} { fold } } -\cs_new:Npn \str_lowercase:n #1 { \@@_change_case:nn {#1} { lower } } -\cs_new:Npn \str_uppercase:n #1 { \@@_change_case:nn {#1} { upper } } -\cs_generate_variant:Nn \str_foldcase:n { V } +\cs_new:Npn \str_casefold:n #1 { \@@_change_case:nn {#1} { casefold } } +\cs_new:Npn \str_lowercase:n #1 { \@@_change_case:nn {#1} { lowercase } } +\cs_new:Npn \str_uppercase:n #1 { \@@_change_case:nn {#1} { uppercase } } +\cs_generate_variant:Nn \str_casefold:n { V } \cs_generate_variant:Nn \str_lowercase:n { f } \cs_generate_variant:Nn \str_uppercase:n { f } \cs_new:Npn \@@_change_case:nn #1 @@ -1962,99 +1968,90 @@ { \@@_if_recursion_tail_stop_do:Nn #2 { \@@_change_case_end:wn } - \@@_change_case_output:fw - { \use:c { char_str_ #1 case:N } #2 } - \@@_change_case_loop:nw {#1} + \@@_change_case_codepoint:nN {#1} #2 } \if_int_compare:w 0 \cs_if_exist:NT \tex_XeTeXversion:D { 1 } \cs_if_exist:NT \tex_luatexversion:D { 1 } > 0 \exp_stop_f: + \cs_new:Npn \@@_change_case_codepoint:nN #1#2 + { \@@_change_case_char:fnn { \int_eval:n {`#2} } {#1} {#2} } \else: - \cs_gset:Npn \@@_change_case_char:nN #1#2 - { - \@@_if_recursion_tail_stop_do:Nn #2 - { \@@_change_case_end:wn } - \int_compare:nNnTF { `#2 } > { "80 } - { - \int_compare:nNnTF { `#2 } < { "E0 } - { \@@_change_case_char_UTFviii:nNN } - { - \int_compare:nNnTF { `#2 } < { "F0 } - { \@@_change_case_char_UTFviii:nNNN } - { \@@_change_case_char_UTFviii:nNNNN } - } - {#1} #2 - } - { - \@@_change_case_output:fw - { \use:c { char_str_ #1 case:N } #2 } - \@@_change_case_loop:nw {#1} - } - } - \cs_new:Npn \@@_change_case_char_UTFviii:nNN #1#2#3 - { \@@_change_case_char_UTFviii:nn {#1} {#2#3} } - \cs_new:Npn \@@_change_case_char_UTFviii:nNNN #1#2#3#4 - { \@@_change_case_char_UTFviii:nn {#1} {#2#3#4} } - \cs_new:Npn \@@_change_case_char_UTFviii:nNNNN #1#2#3#4#5 - { \@@_change_case_char_UTFviii:nn {#1} {#2#3#4#5} } -% \end{macrocode} -% Skip high chars for the Japanese engines. -% \begin{macrocode} - \cs_if_exist:NF \tex_pdftexversion:D - { - \cs_gset:Npn \@@_change_case_char_UTFviii:nNNN #1#2#3#4 - { - \@@_change_case_output:nw {#2#3#4} - \@@_change_case_loop:nw {#1} - } - \cs_gset:Npn \@@_change_case_char_UTFviii:nNNNN #1#2#3#4#5 - { - \@@_change_case_output:nw {#2#3#4#5} - \@@_change_case_loop:nw {#1} - } - } - \cs_new:Npn \@@_change_case_char_UTFviii:nn #1#2 - { - \use:c { @@_change_case_char_UTFviii_ #1 :nn } {#1} {#2} - } - \cs_new:Npn \@@_change_case_char_UTFviii_upper:nn #1#2 - { - \@@_change_case_output:fw - { - \cs_if_exist:cTF { c__kernel_ #1 case_ #2 _tl } - { - \__kernel_tl_to_str:w \exp_after:wN \exp_after:wN \exp_after:wN - { \cs:w c__kernel_ #1 case_ #2 _tl \cs_end: } - } - {#2} - } - \@@_change_case_loop:nw {#1} - } - \cs_new_eq:NN \@@_change_case_char_UTFviii_lower:nn - \@@_change_case_char_UTFviii_upper:nn - \cs_new:Npn \@@_change_case_char_UTFviii_fold:nn #1#2 - { - \@@_change_case_output:fw - { - \cs_if_exist:cTF { c__kernel_ #1 case_ #2 _tl } - { - \__kernel_tl_to_str:w \exp_after:wN \exp_after:wN \exp_after:wN - { \cs:w c__kernel_ #1 case_ #2 _tl \cs_end: } - } - { - \cs_if_exist:cTF { c__kernel_lowercase_ #2 _tl } - { - \__kernel_tl_to_str:w - \exp_after:wN \exp_after:wN \exp_after:wN - { \cs:w c__kernel_lowercase_ #2 _tl \cs_end: } - } - {#2} - } - } - \@@_change_case_loop:nw {#1} - } + \cs_new:Npn \@@_change_case_codepoint:nN #1#2 + { + \int_compare:nNnTF {`#2} > { "80 } + { + \int_compare:nNnTF {`#2} < { "E0 } + { \@@_change_case_codepoint:nNN } + { + \int_compare:nNnTF {`#2} < { "F0 } + { \@@_change_case_codepoint:nNNN } + { \@@_change_case_codepoint:nNNNNN } + } + } + { \@@_change_case_char_aux:nN } + {#1} #2 + } + \cs_new:Npn \@@_change_case_char_aux:nN #1#2 + { \@@_change_case_char:fnn { \int_eval:n {`#2} } {#1} {#2} } + \cs_new:Npn \@@_change_case_codepoint:nNN #1#2#3 + { + \@@_change_case_char:fnn + { \int_eval:n { (`#2 - "C0) * "40 + `#3 - "80 } } + {#1} {#2#3} + } + \cs_new:Npn \@@_change_case_codepoint:nNNN #1#2#3#4 + { + \@@_change_case_char:fnn + { + \int_eval:n + { (`#2 - "E0) * "1000 + (`#3 - "80) * "40 + `#4 - "80 } + } + {#1} {#2#3#4} + } + \cs_new:Npn \@@_change_case_codepoint:nNNNN #1#2#3#4#5 + { + \@@_change_case_char:fnn + { + \int_eval:n + { + (`#2 - "F0) * "40000 + + (`#3 - "80) * "1000 + + (`#4 - "80) * "40 + + `#5 - "80 + } + } + {#1} {#2#3#4#5} + } \fi: +\cs_new:Npn \@@_change_case_char:nnn #1#2#3 + { + \@@_change_case_output:fw + { + \exp_args:Ne \@@_change_case_char_aux:nnn + { \__kernel_codepoint_case:nn {#2} {#1} } {#1} {#3} + } + \@@_change_case_loop:nw {#2} + } +\cs_generate_variant:Nn \@@_change_case_char:nnn { f } +\cs_new:Npn \@@_change_case_char_aux:nnn #1#2#3 + { + \use:e { \@@_change_case_char:nnnnn #1 {#2} {#3} } + } +\cs_new:Npn \@@_change_case_char:nnnnn #1#2#3#4#5 + { + \int_compare:nNnTF {#1} = {#4} + { \tl_to_str:n {#5} } + { + \codepoint_str_generate:n {#1} + \tl_if_blank:nF {#2} + { + \codepoint_str_generate:n {#2} + \tl_if_blank:nF {#3} + { \codepoint_str_generate:n {#3} } + } + } + } % \end{macrocode} % \end{macro} % \end{macro} @@ -2069,6 +2066,8 @@ % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} % % \begin{variable} % { |