aboutsummaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
Diffstat (limited to 'utf8.c')
-rwxr-xr-xutf8.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/utf8.c b/utf8.c
index 20bba73..dd10ae7 100755
--- a/utf8.c
+++ b/utf8.c
@@ -4,14 +4,14 @@ int utf8Next(char** strRef, int* codeRef) {
unsigned char* str = (unsigned char*) *strRef;
unsigned char first = *str;
if (isASCII(first)) {
- *codeRef = *str;
+ *codeRef = first;
++*strRef;
return 0;
}
if (isContinuation(first))
- return ERR_UNEXPECTED_CONTINUATION + first;
+ return ERR_UNEXPECTED_CONTINUATION | first;
if (first >= 248)
- return ERR_INVALID_UTF8_BYTE + first;
+ return ERR_INVALID_UTF8_BYTE | first;
int expectedContinuations =
is2ByteStarter(first) ? 1 :
is3ByteStarter(first) ? 2 : 3;
@@ -20,7 +20,7 @@ int utf8Next(char** strRef, int* codeRef) {
is3ByteStarter(first) ? 224 : 240);
for (int i = 1; i <= expectedContinuations; ++i) {
unsigned char b = str[i];
- if (b > 248) return ERR_INVALID_UTF8_BYTE | (i << 8) | b;
+ if (b >= 248) return ERR_INVALID_UTF8_BYTE | (i << 8) | b;
if (!isContinuation(b)) return ERR_CONTINUATION_EXPECTED | (i << 8) | b;
code = (code << 6) | (b & 0x7f);
}