summaryrefslogtreecommitdiffhomepage
path: root/include/unicode.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/unicode.h')
-rw-r--r--include/unicode.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/unicode.h b/include/unicode.h
index f539e6b..908c75f 100644
--- a/include/unicode.h
+++ b/include/unicode.h
@@ -141,6 +141,11 @@ namespace {
throw std::invalid_argument("Bad input: Invalid 2 byte sequence");
} else
throw std::invalid_argument("Bad input: 2nd byte expected, none found");
+
+ // check only for sequences >= 2 bytes (ASCII is always compliant)
+ if (!unicode::is_valid_unicode(value))
+ throw std::invalid_argument("Invalid Unicode character: "s + std::to_string(static_cast<uint32_t>(value)));
+
} else { // 1 byte: 7 bit ASCII
value = byte0;
sequence_length = 1;