diff options
author | Mattias Andrée <maandree@kth.se> | 2017-11-12 16:16:33 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2017-11-12 16:16:33 +0100 |
commit | 8cef2ca2598cfd0587faf29d0025d68c7dc598ea (patch) | |
tree | ee4737fed27a213869eb5ca005194cadf24b9cd2 /isutf8.c | |
parent | Split into multiple units (diff) | |
download | libsimple-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 'isutf8.c')
-rw-r--r-- | isutf8.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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; } |