aboutsummaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorbluebear94 <[email protected]>2016-07-23 13:18:34 -0400
committerbluebear94 <[email protected]>2016-07-23 13:18:34 -0400
commit8aefd88d00c0bd853fb0f3242d3237868799ed49 (patch)
treec24aa9768b4dc2029fb9691ed68d1785e8c46357 /utf8.c
parentdo not ignore sample target files (diff)
downloadsanstop-master.tar.xz
sanstop-master.zip
Add more configuration optionsHEADmaster
git push -u origin master
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);
}