aboutsummaryrefslogtreecommitdiffstats
path: root/isutf8.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-11-12 16:16:33 +0100
committerMattias Andrée <maandree@kth.se>2017-11-12 16:16:33 +0100
commit8cef2ca2598cfd0587faf29d0025d68c7dc598ea (patch)
treeee4737fed27a213869eb5ca005194cadf24b9cd2 /isutf8.c
parentSplit into multiple units (diff)
downloadlibsimple-8cef2ca2598cfd0587faf29d0025d68c7dc598ea.tar.gz
libsimple-8cef2ca2598cfd0587faf29d0025d68c7dc598ea.tar.bz2
libsimple-8cef2ca2598cfd0587faf29d0025d68c7dc598ea.tar.xz
m + add readme
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--isutf8.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/isutf8.c b/isutf8.c
index 5f63a49..1e87519 100644
--- a/isutf8.c
+++ b/isutf8.c
@@ -29,7 +29,7 @@ libsimple_isutf8(const char *string, int allow_modified_nul)
if ((c & 0xC0) == 0x80)
/* Single-byte character marked as multibyte, or
a non-first byte in a multibyte character. */
- return -1;
+ return 0;
/* Multibyte character. */
while ((c & 0x80))
@@ -39,14 +39,14 @@ libsimple_isutf8(const char *string, int allow_modified_nul)
if (bytes > 6)
/* 31-bit characters can be encoded with 6-bytes,
and UTF-8 does not cover higher code points. */
- return -1;
+ return 0;
} else {
/* Not first byte of the character. */
if ((c & 0xC0) != 0x80)
/* Beginning of new character before a
multibyte character has ended. */
- return -1;
+ return 0;
character = (character << 6) | (c & 0x7F);
@@ -59,7 +59,7 @@ libsimple_isutf8(const char *string, int allow_modified_nul)
character >>= 1, bits++;
bits = (!bits && bytes == 2 && allow_modified_nul) ? 8 : bits;
if (bits < BYTES_TO_MIN_BITS[bytes] || BYTES_TO_MAX_BITS[bytes] < bits)
- return -1;
+ return 0;
read_bytes = bytes = bits = 0;
}