X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=charset%2Funicode.h;h=c0afc17abc9da1cb5c2e172385f7a272cd92de19;hb=68fe13e77b7ceaf950289e747281655ddb264576;hp=5319e3718cbbe320ab07a3ded966dee771e0a86e;hpb=ac9212c1d03bd23f6322bef39a4a0384b5afcc5d;p=libucw.git diff --git a/charset/unicode.h b/charset/unicode.h index 5319e371..c0afc17a 100644 --- a/charset/unicode.h +++ b/charset/unicode.h @@ -1,16 +1,18 @@ /* * The UniCode Library * - * (c) 1997 Martin Mares, + * (c) 1997 Martin Mares + * + * This software may be freely distributed and used according to the terms + * of the GNU Lesser General Public License. */ #ifndef _UNICODE_H #define _UNICODE_H -#include -#include +#include "lib/chartype.h" -extern byte *_U_cat[], *_U_sig[]; +extern byte *_U_cat[]; extern word *_U_upper[], *_U_lower[], *_U_unaccent[]; static inline uns Ucategory(word x) @@ -39,14 +41,6 @@ static inline word Uunaccent(word x) return w ? w : x; } -static inline byte Usig(word x) -{ - if (_U_sig[x >> 8U]) - return _U_sig[x >> 8U][x & 0xff] ? : 0xff; - else - return 0xff; -} - #define UCat(x,y) (Ucategory(x) & (y)) #define Uupper(x) UCat(x, _C_UPPER) @@ -111,6 +105,13 @@ static inline byte Usig(word x) else \ u = *p++ +#define UTF8_SKIP(p) do { \ + uns c = *p++; \ + if (c >= 0xc0) \ + while (c & 0x40 && *p >= 0x80 && *p < 0xc0) \ + p++, c <<= 1; \ + } while (0) + #define UTF8_SPACE(u) ((u) < 0x80 ? 1 : (u) < 0x800 ? 2 : 3) uns ucs2_to_utf8(byte *, word *);