diff --git a/unicodedomino.sty b/unicodedomino.sty
index a0835fea211bd875ee7aa2d43e219ee55ad39195..0d43411790b138ace81a763fa52dc4389c5943e0 100644
--- a/unicodedomino.sty
+++ b/unicodedomino.sty
@@ -196,20 +196,26 @@
 % main handler
 \def\UTFviii@defined#1{%
  \ifx#1\relax%
-  % unknown char
-  \ifx\protect\@typeset@protect%
-   % not protected
-   \PackageWarning{inputenc}{%
-    Unicode\space char\space\expandafter\UTFviii@splitcsname\string#1\relax%
-    \space not\space set\space up\space for\space use\MessageBreak with\space%
-    LaTeX, replacing%
-   }%
-   % note: same warning as in \UTFviii@undefined@err in utf8.def v1.2c,
-   % except adding “, replacing” at the end and not being an error
-   \expandafter\unicodedomino@decode\string#1\relax%
+  \if\relax\expandafter\UTFviii@checkseq\string#1\relax\relax%
+   % unknown char
+   \ifx\protect\@typeset@protect%
+    % not protected
+    \PackageWarning{inputenc}{%
+     Unicode\space char\space\expandafter\UTFviii@splitcsname\string#1\relax%
+     \space not\space set\space up\space for\space use\MessageBreak with\space%
+     LaTeX, replacing%
+    }%
+    % note: same warning as in \UTFviii@undefined@err in utf8.def v1.2c,
+    % except adding “, replacing” at the end and not being an error
+    \expandafter\unicodedomino@decode\string#1\relax%
+   \else%
+    % protected, just write the original character
+    \expandafter\@gobblefour\string#1%
+   \fi%
   \else%
-   % protected, just write the original character
-   \expandafter\@gobblefour\string#1%
+   % invalid encoding
+   \PackageError{inputenc}{Invalid UTF-8 byte sequence}%
+    {Do ensure the source document is saved in UTF-8 encoding.}%
   \fi%
  \else%
   % known char, expand