Update UTF-8 base code
UTF-8 encodes characters in one to four bytes (since 2003). Because 0 is a valid code point, the decode function utf8_ord() should return -1, not 0, on error. As a consequence utf8_width() should return 0 for a continuation byte (as it did previously). Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
committed by
Lukas Fleischer
parent
edc44d613b
commit
95c5d576fa
@@ -225,13 +225,10 @@
|
||||
#define TOSTRING(x) STRINGIFY(x)
|
||||
#define __FILE_POS__ __FILE__ ":" TOSTRING(__LINE__)
|
||||
|
||||
#define UTF8_MAXLEN 6
|
||||
#define UTF8_LENGTH(ch) ((unsigned char)ch >= 0xFC ? 6 : \
|
||||
((unsigned char)ch >= 0xF8 ? 5 : \
|
||||
((unsigned char)ch >= 0xF0 ? 4 : \
|
||||
#define UTF8_MAXLEN 4
|
||||
#define UTF8_LENGTH(ch) ((unsigned char)ch >= 0xF0 ? 4 : \
|
||||
((unsigned char)ch >= 0xE0 ? 3 : \
|
||||
((unsigned char)ch >= 0xC0 ? 2 : 1)))))
|
||||
#define UTF8_ISMULTI(ch) ((unsigned char)ch >= 0x80)
|
||||
((unsigned char)ch >= 0xC0 ? 2 : 1)))
|
||||
#define UTF8_ISCONT(ch) ((unsigned char)ch >= 0x80 && \
|
||||
(unsigned char)ch <= 0xBF)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user