Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
teckids-tex
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Teckids
Team PR
teckids-tex
Commits
9ea69b1a
Commit
9ea69b1a
authored
6 years ago
by
mirabilos
Committed by
mirabilos
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of github.com:mirabilos/tex-unicodedomino
parents
2b9bef1a
b1828bf4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unicodedomino.sty
+70
-17
70 additions, 17 deletions
unicodedomino.sty
with
70 additions
and
17 deletions
unicodedomino.sty
+
70
−
17
View file @
9ea69b1a
...
...
@@ -28,7 +28,7 @@
% makes all UTF-8 available in listings.
\NeedsTeXFormat
{
LaTeX2e
}
%
\ProvidesPackage
{
unicodedomino
}
[2018/08/05 1.
2
Domino for unknown codepoints]
%
\ProvidesPackage
{
unicodedomino
}
[2018/08/05 1.
3
Domino for unknown codepoints]
%
\makeatletter
%
\ifx\numexpr\@
undefined
%
...
...
@@ -37,24 +37,74 @@
\ifx\UTFviii
@defined
\@
undefined
%
\PackageError
{
unicodedomino
}{
This package requires UTF-8 input encoding
}
%
\fi
%
\ifx\decode
@UTFviii
\@
undefined
%
\PackageError
{
unicodedomino
}
%
{
Your utf8.def is too old, consider updating it
}
%
{
You will need Debian stretch or newer
}
%
\fi
%
% patch up bug in utf8.def that forbade 0xF4 lead byte
\begingroup
%
\catcode
`
\~
13
\uccode
`
\~
"F4
\def\UTFviii
@tmp
{
\xdef
~
{
\noexpand\UTFviii
@four@octets
\string
~
}}
%
\uppercase\expandafter
{
\UTFviii
@tmp
}
%
\endgroup
%
% now fixup to disallow too large definitions
\let\unicodedomino
@parse@XML@charref
\parse
@XML@charref
%
\gdef\parse
@XML@charref
{
%
\ifnum\count
@>"10FFFF
\relax
%
\PackageError
{
inputenc
}{
%
Cannot define Unicode char value
\space
%
\unicodedomino
@shex
\the\count
@
\relax\space
(too large)
%
}
%
\fi
%
\unicodedomino
@parse@XML@charref
%
}
%
% nicer printing of codepoint hex numbers, not strictly necessary
\def\unicodedomino
@codepoint#1
{
%
\ifnum
#1>65535
%
\ifnum
#1>1048575
%
U-00
%
\else\ifnum
#1>65535
%
U-000
%
\else\ifnum
#1>4095
%
U+
%
\else
%
\else
\ifnum
#1>255
%
U+0
%
\fi\fi
%
\else\ifnum
#1>15
%
U+00
%
\else
%
U+000
%
\fi\fi\fi\fi\fi
%
\expandafter\UTFviii
@hexnumber
\expandafter
{
#1
}
%
}
%
% same for bytes
\def\unicodedomino
@bytehex#1
{
%
\expandafter\UTFviii
@hexdigit
\expandafter
{
\the\numexpr
(#1-8)/16
\relax
}
%
\UTFviii
@hexdigit
{
\numexpr
#1
\ifnum
#1>0-((#1-8)/16)*16
\fi\relax
}
%
}
%
% and arbitrary numbers
\def\unicodedomino
@shex#1
\relax
{
%
\ifnum
#1>15
%
\expandafter\unicodedomino
@shex
\expandafter\the\numexpr
(#1-8)/16
\relax
%
\fi
%
\UTFviii
@hexdigit
{
\numexpr
#1
\ifnum
#1>0-((#1-8)/16)*16
\fi\relax
}
%
}
%
% override to beautify the output, not strictly necessary but requested
\gdef\UTFviii
@splitcsname#1:#2
\relax
{
%
#2 (
\expandafter\unicodedomino
@codepoint
\expandafter
{
%
\the\numexpr\decode
@UTFviii#2
\relax
}
)
%
}
%
\def\UTFviii
@invalid@err#1
{
%
\PackageError
{
inputenc
}{
%
Invalid UTF-8 byte 0x
\unicodedomino
@bytehex
{
\number
`#1
}
%
}
\UTFviii
@invalid@help
%
}
%
% for invalid encoding output
\gdef\unicodedomino
@splith@x#1#2
\relax
{
%
...
...
@@ -83,22 +133,25 @@
}
%
% expand all hex nybbles, zero-padded
\def\unicodedomino
@hex@ll#1
{
%
\ifnum
#1<1048576 0.
\fi
%
\ifnum
#1<65536 0.
\fi
%
\ifnum
#1<4096 0.
\fi
%
\ifnum
#1<256 0.
\fi
%
\ifnum
#1<16 0.
\fi
%
\expandafter\unicodedomino
@hex@ne
\expandafter
{
#1
}
%
}
%
% call the appropriate box function
\def\unicodedomino
@hex@do#1.#2.#3.#4.#5.
{
%
\ifnum
#1
>
0
%
\unicodedomino
@box
{
0#1#2
}{
#3#4#5
}
%
\def\unicodedomino
@hex@do#1.#2.#3.#4.#5.
#6.
{
%
\ifnum
"
#1
#2=
0
%
\unicodedomino
@box
{
#3#4
}{
#5#6
}
%
\else
%
\unicodedomino
@box
{
#2#3
}{
#4#5
}
%
\unicodedomino
@box
{
#
1#
2#3
}{
#4#5
#6
}
%
\fi
%
}
%
% split nybbles and pass on
\protected\def\unicodedomino
@hex#1
{
%
\edef\t
e
mp
{
\expandafter\unicodedomino
@hex@ll
\expandafter
{
#1
}}
%
\expandafter\unicodedomino
@hex@do
\t
e
mp\relax
%
\edef\
unicodedomino
@
tmp
{
\expandafter\unicodedomino
@hex@ll
\expandafter
{
#1
}}
%
\expandafter\unicodedomino
@hex@do
\
unicodedomino
@
tmp
\relax
%
}
%
% split, decode and pass on
\def\unicodedomino
@decode#1:#2
\relax
{
%
...
...
@@ -126,16 +179,16 @@
% collect octet tokens, trim them, pass on to handler
\long\def\UTFviii
@two@octets#1#2
{
%
\edef\t
e
mp
{
#1
\unicodedomino
@last
{
\string
#2
}}
%
\expandafter\unicodedomino
@octets
\t
e
mp\empty
%
\edef\
unicodedomino
@
tmp
{
#1
\unicodedomino
@last
{
\string
#2
}}
%
\expandafter\unicodedomino
@octets
\
unicodedomino
@
tmp
\empty
%
}
%
\long\def\UTFviii
@three@octets#1#2#3
{
%
\edef\t
e
mp
{
#1
\unicodedomino
@last
{
\string
#2
}
\unicodedomino
@last
{
\string
#3
}}
%
\expandafter\unicodedomino
@octets
\t
e
mp\empty
%
\edef\
unicodedomino
@
tmp
{
#1
\unicodedomino
@last
{
\string
#2
}
\unicodedomino
@last
{
\string
#3
}}
%
\expandafter\unicodedomino
@octets
\
unicodedomino
@
tmp
\empty
%
}
%
\long\def\UTFviii
@four@octets#1#2#3#4
{
%
\edef\t
e
mp
{
#1
\unicodedomino
@last
{
\string
#2
}
\unicodedomino
@last
{
\string
#3
}
\unicodedomino
@last
{
\string
#4
}}
%
\expandafter\unicodedomino
@octets
\t
e
mp\empty
%
\edef\
unicodedomino
@
tmp
{
#1
\unicodedomino
@last
{
\string
#2
}
\unicodedomino
@last
{
\string
#3
}
\unicodedomino
@last
{
\string
#4
}}
%
\expandafter\unicodedomino
@octets
\
unicodedomino
@
tmp
\empty
%
}
%
% main handler
...
...
@@ -162,7 +215,7 @@
\PackageError
{
inputenc
}{
%
Invalid
\space
UTF-8
\space
byte
\space
sequence:
%
\expandafter\unicodedomino
@splithex
\string
#1
\relax
%
}{
Do ensure the source document is saved in UTF-8 encoding
.
}
%
}{
Do ensure the source document is saved in UTF-8 encoding
}
%
\fi
%
\else
%
% known char, expand
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment