diff options
| author | bluebear94 <[email protected]> | 2016-07-23 13:18:34 -0400 |
|---|---|---|
| committer | bluebear94 <[email protected]> | 2016-07-23 13:18:34 -0400 |
| commit | 8aefd88d00c0bd853fb0f3242d3237868799ed49 (patch) | |
| tree | c24aa9768b4dc2029fb9691ed68d1785e8c46357 /utf8.c | |
| parent | do not ignore sample target files (diff) | |
| download | sanstop-master.tar.xz sanstop-master.zip | |
git push -u origin master
Diffstat (limited to 'utf8.c')
| -rwxr-xr-x | utf8.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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);
}
|