summaryrefslogtreecommitdiffhomepage
path: root/include/unicode/utf.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/unicode/utf.h')
-rw-r--r--include/unicode/utf.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/include/unicode/utf.h b/include/unicode/utf.h
index 691d4ba..0738242 100644
--- a/include/unicode/utf.h
+++ b/include/unicode/utf.h
@@ -58,13 +58,13 @@ namespace unicode::detail {
while (i < size) {
if (is_utf8_sequence(s[i])) {
i++;
- } else if ((i < size - 1) && is_utf8_sequence(s[i], s[i + 1])) {
+ } else if ((i + 1 < size) && is_utf8_sequence(s[i], s[i + 1])) {
i += 2;
- } else if ((i < size - 2) && is_utf8_sequence(s[i], s[i + 1], s[i + 2])) {
+ } else if ((i + 2 < size) && is_utf8_sequence(s[i], s[i + 1], s[i + 2])) {
if (((s[i] & 0xF) == 0xD) && ((s[i + 1] & 0x20) == 0x20))
return false; // Reserved for UTF-16 surrogates: 0xD800..0xDFFF
i += 3;
- } else if ((i < size - 3) && is_utf8_sequence(s[i], s[i + 1], s[i + 2], s[i + 3])) {
+ } else if ((i + 3 < size) && is_utf8_sequence(s[i], s[i + 1], s[i + 2], s[i + 3])) {
if ((((s[i] & 7) << 2) | ((s[i + 1] >> 4) & 3)) >= 0x11)
return false; // Unicode too big above 0x10FFFF
i += 4;
@@ -101,7 +101,7 @@ namespace unicode::detail {
while (i < size) {
if (is_utf16_sequence(s[i])) {
i++;
- } else if ((i < size - 1) && is_utf16_sequence(s[i], s[i + 1])) {
+ } else if ((i + 1 < size) && is_utf16_sequence(s[i], s[i + 1])) {
i += 2;
} else
#if __cplusplus >= 202002L