From 8043d841d34bb5a4274fdd0757515e55ae2b3193 Mon Sep 17 00:00:00 2001
From: mirabilos <m@mirbsd.org>
Date: Sun, 5 Aug 2018 17:59:09 +0200
Subject: [PATCH] beautify stock Invalid UTF-8 byte output: use hex for
 printing char

---
 unicodedomino.sty | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/unicodedomino.sty b/unicodedomino.sty
index b69897e..f52b6f7 100644
--- a/unicodedomino.sty
+++ b/unicodedomino.sty
@@ -54,11 +54,22 @@
  \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}%
+}%
+
 % 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{%
-- 
GitLab