[latex3-commits] [git/LaTeX3-latex3-latex3] text-case: Move definition of \char_codepoint_to_bytes:n (93c330b50)

Joseph Wright joseph.wright at morningstar2.co.uk
Thu Jan 9 14:51:25 CET 2020


Repository : https://github.com/latex3/latex3
On branch  : text-case
Link       : https://github.com/latex3/latex3/commit/93c330b5024dad1107409ea1bcc59265528e1b03

>---------------------------------------------------------------

commit 93c330b5024dad1107409ea1bcc59265528e1b03
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Thu Jan 2 21:39:10 2020 +0000

    Move definition of \char_codepoint_to_bytes:n
    
    Still experimental but has to come before the text functions.


>---------------------------------------------------------------

93c330b5024dad1107409ea1bcc59265528e1b03
 l3kernel/l3candidates.dtx | 111 ----------------------------------------------
 l3kernel/l3token.dtx      | 105 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 105 insertions(+), 111 deletions(-)

diff --git a/l3kernel/l3candidates.dtx b/l3kernel/l3candidates.dtx
index 648d53096..d8920a5bc 100644
--- a/l3kernel/l3candidates.dtx
+++ b/l3kernel/l3candidates.dtx
@@ -1630,117 +1630,6 @@
 % appropriate data extracted from the Unicode documentation (either manually
 % or automatically).
 %
-% First, some code which \enquote{belongs} in \pkg{l3tokens} but has to come
-% here.
-%    \begin{macrocode}
-%<@@=char>
-%    \end{macrocode}
-%
-% \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}
 \cs_new_eq:NN \char_mixedcase:N \char_titlecase:N
 %     \end{macrocode}
diff --git a/l3kernel/l3token.dtx b/l3kernel/l3token.dtx
index 861697194..dc7851c1d 100644
--- a/l3kernel/l3token.dtx
+++ b/l3kernel/l3token.dtx
@@ -1553,6 +1553,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}[rEXP]{\char_to_nfd:N}
 % \begin{macro}[rEXP]{\@@_to_nfd:n}
 % \begin{macro}[rEXP]{\@@_to_nfd:Nw}





More information about the latex3-commits mailing list