#include typedef unsigned int ucs4_t; #define header_0 16 #define header_2 9 #define header_3 127 #define header_4 15 static const struct { int header[1]; int level1[1]; short level2[1 << 7]; /*unsigned*/ int level3[1 << 4]; } u_categ_Cc = { { 1 }, { 2 * sizeof (int) / sizeof (short) + 0 }, { 2 + 128 * sizeof (short) / sizeof (int) + 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { 0xFFFFFFFF, 0x00000000, 0x00000000, 0x80000000, 0xFFFFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } }; static inline int bitmap_lookup (const void *table, ucs4_t uc) { unsigned int index1 = uc >> header_0; if (index1 < ((const int *) table)[0]) { int lookup1 = ((const int *) table)[1 + index1]; if (lookup1 >= 0) { unsigned int index2 = (uc >> header_2) & header_3; int lookup2 = ((const short *) table)[lookup1 + index2]; if (lookup2 >= 0) { unsigned int index3 = (uc >> 5) & header_4; unsigned int lookup3 = ((const int *) table)[lookup2 + index3]; return (lookup3 >> (uc & 0x1f)) & 1; } } } return 0; } bool uc_is_general_category_Cc (ucs4_t uc) { return bitmap_lookup (&u_categ_Cc, uc); }