Validate utf8

This commit is contained in:
2025-05-18 17:23:22 -04:00
parent 452bbd3d9c
commit d279173482
6 changed files with 105 additions and 95 deletions

View File

@@ -6,13 +6,13 @@ constexpr inline struct Tables {
whitespace['\n'] = true;
whitespace['\r'] = true;
whitespace['\t'] = true;
for (int i = 0; i < 10; ++i) {
number['0' + i] = true;
invalidUtf8[0xc0] = true;
invalidUtf8[0xc1] = true;
for (int i = 0xf5; i <= 0xff; ++i) {
invalidUtf8[i] = true;
}
number['.'] = true;
number['+'] = true;
number['-'] = true;
}
alignas(16) bool whitespace[256]{};
alignas(16) bool number[256]{};
alignas(16) bool invalidUtf8[256]{};
} tables;