summaryrefslogtreecommitdiff
path: root/unicode.h
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-02-16 12:33:11 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-02-16 12:33:11 -0500
commit824c4ff4be5a0bf55b6644fed06fcfe2248c4301 (patch)
tree0eb56394e769e23005a9f03ffea0557c2577e542 /unicode.h
parent4bde24cb63313f636ac72b449f54d68515efe485 (diff)
started getting :build to work
Diffstat (limited to 'unicode.h')
-rw-r--r--unicode.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/unicode.h b/unicode.h
index 53941d2..211efd6 100644
--- a/unicode.h
+++ b/unicode.h
@@ -14,7 +14,8 @@ static bool unicode_is_start_of_code_point(u8 byte) {
// number of bytes that can be read from `str`.
// Returns:
// 0 - if a NULL character was encountered
-// (size_t)-1 - on invalid UTF-8 / incomplete code point
+// (size_t)-1 - on invalid UTF-8
+// (size_t)-2 - on incomplete code point (str should be longer)
// other - the number of bytes read from `str`.
static size_t unicode_utf8_to_utf32(char32_t *c, char const *str, size_t bytes) {
if (bytes == 0) {
@@ -39,7 +40,7 @@ static size_t unicode_utf8_to_utf32(char32_t *c, char const *str, size_t bytes)
} else {
// incomplete code point
*c = 0;
- return (size_t)-1;
+ return (size_t)-2;
}
}
if ((first_byte & 0xF0) == 0xE0) {
@@ -63,7 +64,7 @@ static size_t unicode_utf8_to_utf32(char32_t *c, char const *str, size_t bytes)
} else {
// incomplete
*c = 0;
- return (size_t)-1;
+ return (size_t)-2;
}
}
if ((first_byte & 0xF8) == 0xF0) {
@@ -90,7 +91,7 @@ static size_t unicode_utf8_to_utf32(char32_t *c, char const *str, size_t bytes)
} else {
// incomplete
*c = 0;
- return (size_t)-1;
+ return (size_t)-2;
}
}
// invalid UTF-8