[latex3-commits] [git/LaTeX3-latex3-latex3] l3text: Move \char_codepoint_to_bytes:n to stable (28026623a)
Joseph Wright
joseph.wright at morningstar2.co.uk
Wed Nov 27 11:23:26 CET 2019
Repository : https://github.com/latex3/latex3
On branch : l3text
Link : https://github.com/latex3/latex3/commit/28026623a5333b114d96bbc0ab5d1f5e3114f762
>---------------------------------------------------------------
commit 28026623a5333b114d96bbc0ab5d1f5e3114f762
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Tue Nov 26 19:53:33 2019 +0000
Move \char_codepoint_to_bytes:n to stable
>---------------------------------------------------------------
28026623a5333b114d96bbc0ab5d1f5e3114f762
l3kernel/CHANGELOG.md | 1 +
l3kernel/l3candidates.dtx | 117 ---------------------------------------------
l3kernel/l3token.dtx | 119 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 120 insertions(+), 117 deletions(-)
diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 87624e21d..96a06f4d2 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -12,6 +12,7 @@ this project uses date-based 'snapshot' version identifiers.
### Changed
- Distribute LaTeX3 News
+- Moved `\char_codepoint_to_bytes:n` to stable
## [2019-11-07]
diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index b4eda0652..f5d1d53fb 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -868,18 +868,6 @@
% the character had been read directly here).
% \end{function}
%
-% \begin{function}[added = 2018-06-01, EXP]{\char_codepoint_to_bytes:n}
-% \begin{syntax}
-% \cs{char_codepoint_to_bytes:n} \Arg{codepoint}
-% \end{syntax}
-% Converts the (Unicode) \meta{codepoint} to UTF-8 bytes. The expansion
-% of this function comprises four brace groups, each of which will contain
-% a hexadecimal value: the appropriate byte. As UTF-8 is a variable-length,
-% one or more of the grouos may be empty: the bytes read in the logical order,
-% such that a two-byte codepoint will have groups |#1| and |#2| filled
-% and |#3| and |#4| empty.
-% \end{function}
-%
% \begin{function}[added = 2018-09-23]
% {
% \peek_catcode_collect_inline:Nn,
@@ -1731,111 +1719,6 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}[EXP]{\char_codepoint_to_bytes:n}
-% \begin{macro}[EXP]{\@@_codepoint_to_bytes_auxi:n}
-% \begin{macro}[EXP]{\@@_codepoint_to_bytes_auxii:Nnn}
-% \begin{macro}[EXP]{\@@_codepoint_to_bytes_auxiii:n}
-% \begin{macro}[EXP]
-% {
-% \@@_codepoint_to_bytes_outputi:nw ,
-% \@@_codepoint_to_bytes_outputii:nw ,
-% \@@_codepoint_to_bytes_outputiii:nw ,
-% \@@_codepoint_to_bytes_outputiv:nw
-% }
-% \begin{macro}[EXP]
-% {\@@_codepoint_to_bytes_output:nnn, \@@_codepoint_to_bytes_output:fnn}
-% \begin{macro}[EXP]{\@@_codepoint_to_bytes_end:}
-% This code converts a codepoint into the correct UTF-8 representation.
-% In terms of the algorithm itself, see
-% \url{https://en.wikipedia.org/wiki/UTF-8} for the octet pattern.
-% \begin{macrocode}
-\cs_new:Npn \char_codepoint_to_bytes:n #1
- {
- \exp_args:Nf \@@_codepoint_to_bytes_auxi:n
- { \int_eval:n {#1} }
- }
-\cs_new:Npn \@@_codepoint_to_bytes_auxi:n #1
- {
- \if_int_compare:w #1 > "80 \exp_stop_f:
- \if_int_compare:w #1 < "800 \exp_stop_f:
- \@@_codepoint_to_bytes_outputi:nw
- { \@@_codepoint_to_bytes_auxii:Nnn C {#1} { 64 } }
- \@@_codepoint_to_bytes_outputii:nw
- { \@@_codepoint_to_bytes_auxiii:n {#1} }
- \else:
- \if_int_compare:w #1 < "10000 \exp_stop_f:
- \@@_codepoint_to_bytes_outputi:nw
- { \@@_codepoint_to_bytes_auxii:Nnn E {#1} { 64 * 64 } }
- \@@_codepoint_to_bytes_outputii:nw
- {
- \@@_codepoint_to_bytes_auxiii:n
- { \int_div_truncate:nn {#1} { 64 } }
- }
- \@@_codepoint_to_bytes_outputiii:nw
- { \@@_codepoint_to_bytes_auxiii:n {#1} }
- \else:
- \@@_codepoint_to_bytes_outputi:nw
- {
- \@@_codepoint_to_bytes_auxii:Nnn F
- {#1} { 64 * 64 * 64 }
- }
- \@@_codepoint_to_bytes_outputii:nw
- {
- \@@_codepoint_to_bytes_auxiii:n
- { \int_div_truncate:nn {#1} { 64 * 64 } }
- }
- \@@_codepoint_to_bytes_outputiii:nw
- {
- \@@_codepoint_to_bytes_auxiii:n
- { \int_div_truncate:nn {#1} { 64 } }
- }
- \@@_codepoint_to_bytes_outputiv:nw
- { \@@_codepoint_to_bytes_auxiii:n {#1} }
- \fi:
- \fi:
- \else:
- \@@_codepoint_to_bytes_outputi:nw {#1}
- \fi:
- \@@_codepoint_to_bytes_end: { } { } { } { }
- }
-\cs_new:Npn \@@_codepoint_to_bytes_auxii:Nnn #1#2#3
- { "#10 + \int_div_truncate:nn {#2} {#3} }
-\cs_new:Npn \@@_codepoint_to_bytes_auxiii:n #1
- { \int_mod:nn {#1} { 64 } + 128 }
-\cs_new:Npn \@@_codepoint_to_bytes_outputi:nw
- #1 #2 \@@_codepoint_to_bytes_end: #3
- { \@@_codepoint_to_bytes_output:fnn { \int_eval:n {#1} } { } {#2} }
-\cs_new:Npn \@@_codepoint_to_bytes_outputii:nw
- #1 #2 \@@_codepoint_to_bytes_end: #3#4
- { \@@_codepoint_to_bytes_output:fnn { \int_eval:n {#1} } { {#3} } {#2} }
-\cs_new:Npn \@@_codepoint_to_bytes_outputiii:nw
- #1 #2 \@@_codepoint_to_bytes_end: #3#4#5
- {
- \@@_codepoint_to_bytes_output:fnn
- { \int_eval:n {#1} } { {#3} {#4} } {#2}
- }
-\cs_new:Npn \@@_codepoint_to_bytes_outputiv:nw
- #1 #2 \@@_codepoint_to_bytes_end: #3#4#5#6
- {
- \@@_codepoint_to_bytes_output:fnn
- { \int_eval:n {#1} } { {#3} {#4} {#5} } {#2}
- }
-\cs_new:Npn \@@_codepoint_to_bytes_output:nnn #1#2#3
- {
- #3
- \@@_codepoint_to_bytes_end: #2 {#1}
- }
-\cs_generate_variant:Nn \@@_codepoint_to_bytes_output:nnn { f }
-\cs_new:Npn \@@_codepoint_to_bytes_end: { }
-% \end{macrocode}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-%
% \begin{macrocode}
%<@@=tl>
% \end{macrocode}
diff --git a/l3kernel/l3token.dtx b/l3kernel/l3token.dtx
index 36ca72007..672cf04bf 100644
--- a/l3kernel/l3token.dtx
+++ b/l3kernel/l3token.dtx
@@ -399,6 +399,20 @@
% general document use.
% \end{variable}
%
+% \subsection{Converting character tokens}
+%
+% \begin{function}[added = 2018-06-01, EXP]{\char_codepoint_to_bytes:n}
+% \begin{syntax}
+% \cs{char_codepoint_to_bytes:n} \Arg{codepoint}
+% \end{syntax}
+% Converts the (Unicode) \meta{codepoint} to UTF-8 bytes. The expansion
+% of this function comprises four brace groups, each of which will contain
+% a hexadecimal value: the appropriate byte. As UTF-8 is a variable-length,
+% one or more of the groups may be empty: the bytes read in the logical order,
+% such that a two-byte codepoint will have groups |#1| and |#2| filled
+% and |#3| and |#4| empty.
+% \end{function}
+%
% \section{Generic tokens}
%
% \begin{variable}
@@ -1532,6 +1546,111 @@
% \end{macro}
% \end{macro}
%
+% \begin{macro}[EXP]{\char_codepoint_to_bytes:n}
+% \begin{macro}[EXP]{\@@_codepoint_to_bytes_auxi:n}
+% \begin{macro}[EXP]{\@@_codepoint_to_bytes_auxii:Nnn}
+% \begin{macro}[EXP]{\@@_codepoint_to_bytes_auxiii:n}
+% \begin{macro}[EXP]
+% {
+% \@@_codepoint_to_bytes_outputi:nw ,
+% \@@_codepoint_to_bytes_outputii:nw ,
+% \@@_codepoint_to_bytes_outputiii:nw ,
+% \@@_codepoint_to_bytes_outputiv:nw
+% }
+% \begin{macro}[EXP]
+% {\@@_codepoint_to_bytes_output:nnn, \@@_codepoint_to_bytes_output:fnn}
+% \begin{macro}[EXP]{\@@_codepoint_to_bytes_end:}
+% This code converts a codepoint into the correct UTF-8 representation.
+% In terms of the algorithm itself, see
+% \url{https://en.wikipedia.org/wiki/UTF-8} for the octet pattern.
+% \begin{macrocode}
+\cs_new:Npn \char_codepoint_to_bytes:n #1
+ {
+ \exp_args:Nf \@@_codepoint_to_bytes_auxi:n
+ { \int_eval:n {#1} }
+ }
+\cs_new:Npn \@@_codepoint_to_bytes_auxi:n #1
+ {
+ \if_int_compare:w #1 > "80 \exp_stop_f:
+ \if_int_compare:w #1 < "800 \exp_stop_f:
+ \@@_codepoint_to_bytes_outputi:nw
+ { \@@_codepoint_to_bytes_auxii:Nnn C {#1} { 64 } }
+ \@@_codepoint_to_bytes_outputii:nw
+ { \@@_codepoint_to_bytes_auxiii:n {#1} }
+ \else:
+ \if_int_compare:w #1 < "10000 \exp_stop_f:
+ \@@_codepoint_to_bytes_outputi:nw
+ { \@@_codepoint_to_bytes_auxii:Nnn E {#1} { 64 * 64 } }
+ \@@_codepoint_to_bytes_outputii:nw
+ {
+ \@@_codepoint_to_bytes_auxiii:n
+ { \int_div_truncate:nn {#1} { 64 } }
+ }
+ \@@_codepoint_to_bytes_outputiii:nw
+ { \@@_codepoint_to_bytes_auxiii:n {#1} }
+ \else:
+ \@@_codepoint_to_bytes_outputi:nw
+ {
+ \@@_codepoint_to_bytes_auxii:Nnn F
+ {#1} { 64 * 64 * 64 }
+ }
+ \@@_codepoint_to_bytes_outputii:nw
+ {
+ \@@_codepoint_to_bytes_auxiii:n
+ { \int_div_truncate:nn {#1} { 64 * 64 } }
+ }
+ \@@_codepoint_to_bytes_outputiii:nw
+ {
+ \@@_codepoint_to_bytes_auxiii:n
+ { \int_div_truncate:nn {#1} { 64 } }
+ }
+ \@@_codepoint_to_bytes_outputiv:nw
+ { \@@_codepoint_to_bytes_auxiii:n {#1} }
+ \fi:
+ \fi:
+ \else:
+ \@@_codepoint_to_bytes_outputi:nw {#1}
+ \fi:
+ \@@_codepoint_to_bytes_end: { } { } { } { }
+ }
+\cs_new:Npn \@@_codepoint_to_bytes_auxii:Nnn #1#2#3
+ { "#10 + \int_div_truncate:nn {#2} {#3} }
+\cs_new:Npn \@@_codepoint_to_bytes_auxiii:n #1
+ { \int_mod:nn {#1} { 64 } + 128 }
+\cs_new:Npn \@@_codepoint_to_bytes_outputi:nw
+ #1 #2 \@@_codepoint_to_bytes_end: #3
+ { \@@_codepoint_to_bytes_output:fnn { \int_eval:n {#1} } { } {#2} }
+\cs_new:Npn \@@_codepoint_to_bytes_outputii:nw
+ #1 #2 \@@_codepoint_to_bytes_end: #3#4
+ { \@@_codepoint_to_bytes_output:fnn { \int_eval:n {#1} } { {#3} } {#2} }
+\cs_new:Npn \@@_codepoint_to_bytes_outputiii:nw
+ #1 #2 \@@_codepoint_to_bytes_end: #3#4#5
+ {
+ \@@_codepoint_to_bytes_output:fnn
+ { \int_eval:n {#1} } { {#3} {#4} } {#2}
+ }
+\cs_new:Npn \@@_codepoint_to_bytes_outputiv:nw
+ #1 #2 \@@_codepoint_to_bytes_end: #3#4#5#6
+ {
+ \@@_codepoint_to_bytes_output:fnn
+ { \int_eval:n {#1} } { {#3} {#4} {#5} } {#2}
+ }
+\cs_new:Npn \@@_codepoint_to_bytes_output:nnn #1#2#3
+ {
+ #3
+ \@@_codepoint_to_bytes_end: #2 {#1}
+ }
+\cs_generate_variant:Nn \@@_codepoint_to_bytes_output:nnn { f }
+\cs_new:Npn \@@_codepoint_to_bytes_end: { }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
% \begin{macro}{\c_catcode_other_space_tl}
% Create a space with category code $12$: an \enquote{other} space.
% \begin{macrocode}
More information about the latex3-commits
mailing list