diff options
author | Roland Reichwein <mail@reichwein.it> | 2022-12-15 11:01:37 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2022-12-15 11:01:37 +0100 |
commit | 55d1d3612141ef1fe858b2bccb950da51cfe7a17 (patch) | |
tree | 50cc3a90dd5d3eea8e4f1020da165e2bc31e0556 /include | |
parent | 53e50b9fd7f051d039e40f77fa00498dd9a8e2b0 (diff) |
Diffstat (limited to 'include')
-rw-r--r-- | include/unicode/utf.h | 8 |
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 |