From 7f5fc0c62f824282b910a573baf6c2712ca33cbe Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sun, 29 May 2011 21:32:34 +0200 Subject: src/calcurse.h: Add UTF-8 related macros Signed-off-by: Lukas Fleischer --- src/calcurse.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/calcurse.h b/src/calcurse.h index 6642ae9..d7fa770 100644 --- a/src/calcurse.h +++ b/src/calcurse.h @@ -200,6 +200,14 @@ #define TOSTRING(x) STRINGIFY(x) #define __FILE_POS__ __FILE__ ":" TOSTRING(__LINE__) +#define UTF8_LENGTH(ch) ((unsigned char)ch >= 0xFC ? 6 : \ + ((unsigned char)ch >= 0xF8 ? 5 : \ + ((unsigned char)ch >= 0xF0 ? 4 : \ + ((unsigned char)ch >= 0xE0 ? 3 : \ + ((unsigned char)ch >= 0xC0 ? 2 : 1))))) +#define UTF8_ISCONT(ch) ((unsigned char)ch >= 0x80 && \ + (unsigned char)ch <= 0xBF) + #define MAX(x,y) ((x)>(y)?(x):(y)) #define MIN(x,y) ((x)<(y)?(x):(y)) -- cgit v1.2.3-70-g09d2