diff options
author | Lars Henriksen <LarsHenriksen@get2net.dk> | 2017-11-29 22:19:10 +0100 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2017-12-07 09:02:58 +0100 |
commit | 95c5d576fafa2f705e6562f57bab9a9d583c8776 (patch) | |
tree | 475b7ef3fb9831a094aec2eb562bef38a94be0f2 /src/calcurse.h | |
parent | edc44d613bdc57566a48ea855af86a9df0b3d13d (diff) | |
download | calcurse-95c5d576fafa2f705e6562f57bab9a9d583c8776.tar.gz calcurse-95c5d576fafa2f705e6562f57bab9a9d583c8776.zip |
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>
Diffstat (limited to 'src/calcurse.h')
-rw-r--r-- | src/calcurse.h | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/calcurse.h b/src/calcurse.h index f4f0e6c..5bf32cf 100644 --- a/src/calcurse.h +++ b/src/calcurse.h @@ -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) |