diff options
author | Lukas Fleischer <calcurse@cryptocrack.de> | 2011-05-29 21:32:34 +0200 |
---|---|---|
committer | Lukas Fleischer <calcurse@cryptocrack.de> | 2011-06-29 15:43:44 +0200 |
commit | 7f5fc0c62f824282b910a573baf6c2712ca33cbe (patch) | |
tree | 2a527b38a1347baa1d1893e9f7c1cf2e9e838b1a | |
parent | 470f05cd383800529a5acb10bb52debbf9b24388 (diff) | |
download | calcurse-7f5fc0c62f824282b910a573baf6c2712ca33cbe.tar.gz calcurse-7f5fc0c62f824282b910a573baf6c2712ca33cbe.zip |
src/calcurse.h: Add UTF-8 related macros
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
-rw-r--r-- | src/calcurse.h | 8 |
1 files changed, 8 insertions, 0 deletions
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)) |