diff options
| author | Mattias Andrée <m@maandree.se> | 2026-01-24 17:27:23 +0100 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-01-24 17:27:23 +0100 |
| commit | be3e7dec7e19a8ddc527a188306c097900a6da99 (patch) | |
| tree | 094d0c9bd936dc1c5853210f3ae94455b670748d /libcharconv_decode_utf8_.c | |
| parent | Make UTF-8 decoding function available to the entire library (diff) | |
| download | charconv-be3e7dec7e19a8ddc527a188306c097900a6da99.tar.gz charconv-be3e7dec7e19a8ddc527a188306c097900a6da99.tar.bz2 charconv-be3e7dec7e19a8ddc527a188306c097900a6da99.tar.xz | |
Add bracketed
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libcharconv_decode_utf8_.c')
| -rw-r--r-- | libcharconv_decode_utf8_.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libcharconv_decode_utf8_.c b/libcharconv_decode_utf8_.c index db66040..7b488e3 100644 --- a/libcharconv_decode_utf8_.c +++ b/libcharconv_decode_utf8_.c @@ -1,5 +1,7 @@ /* See LICENSE file for copyright and license details. */ #include "lib-common.h" +#include <stdlib.h> +#include <stdio.h> size_t @@ -37,6 +39,8 @@ libcharconv_decode_utf8_(const char *s, size_t slen, uint_least32_t *cp) return n; for (i = 1u; i < n; i++) { + if ((s[i] & 0xC0) != 0x80) + return 0u; *cp <<= 6; *cp |= (uint_least32_t)s[i] & 0x3Fu; } |
