[latex3-commits] [git/LaTeX3-latex3-latex2e] master: cosmetics: format Unicode codepoints properly (8cfb6ba)

David Carlisle d.p.carlisle at gmail.com
Sun Sep 30 16:29:17 CEST 2018


Repository : https://github.com/latex3/latex2e
On branch  : master
Link       : https://github.com/latex3/latex2e/commit/8cfb6ba3bb55c39c0b720d3a6957b4b0780d357e

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

commit 8cfb6ba3bb55c39c0b720d3a6957b4b0780d357e
Author: mirabilos <m at mirbsd.org>
Date:   Sun Aug 5 22:14:01 2018 +0200

    cosmetics: format Unicode codepoints properly
    
    Instead of just writing U+ and the codepoint in hex, format them
    as U+XXXX for BMP codepoints and U-XXXXXXXX for astral planes.


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

8cfb6ba3bb55c39c0b720d3a6957b4b0780d357e
 base/utf8ienc.dtx |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/base/utf8ienc.dtx b/base/utf8ienc.dtx
index 39dd704..ee77f19 100644
--- a/base/utf8ienc.dtx
+++ b/base/utf8ienc.dtx
@@ -808,23 +808,37 @@
 %
 % \begin{macro}{\UTFviii at splitcsname}
 % \changes{v1.1o}{2015/08/28}{Macro added}
+% \begin{macro}{\UTFviii at hexcodepoint}
+% \changes{v1.2e}{2018/08/05}{Format codepoint properly}
 %    Split a csname representing a unicode character and return
 %    the character and (if |\numexpr| is defined) the unicode number in hex.
 %    \begin{macrocode}
 \ifx\numexpr\@undefined
+\gdef\UTFviii at hexcodepoint#1{#1}%
 \gdef\UTFviii at splitcsname#1:#2\relax{#2}}
 \else
+\gdef\UTFviii at hexcodepoint#1{%
+ \ifnum#1<16 U+000%
+ \else\ifnum#1<256 U+00%
+ \else\ifnum#1<4096 U+0%
+ \else\ifnum#1<65536 U+%
+ \else\ifnum#1<1048576 U-000%
+ \else U-00%
+ \fi\fi\fi\fi\fi%
+ \UTFviii at hexnumber{#1}%
+}%
 \gdef\UTFviii at splitcsname#1:#2\relax{%
 %    \end{macrocode}
 % \changes{v1.2b}{2018/03/26}{add percent as \cs{endlinechar} not -1 in the format}%
 % Need to pre-expand the argument to ensure cleanup in case of mal-formed UTF-8.
 %    \begin{macrocode}
-#2 (U+\expandafter\UTFviii at hexnumber\expandafter{%
+#2 (\expandafter\UTFviii at hexcodepoint\expandafter{%
                      \the\numexpr\decode at UTFviii#2\relax})%
 }
 \fi
 %    \end{macrocode}
 % \end{macro}
+% \end{macro}
 %
 %    \begin{macrocode}
 \endgroup





More information about the latex3-commits mailing list