00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef UTF8INTERNAL_H
00026 #define UTF8INTERNAL_H
00027
00036 #define UTF8_ANALYZE(s, ascii, latin1, ucs2, ucs4, errors) \
00037 do { \
00038 if (s) while (*s) { \
00039 utf8 c = *s++; \
00040 if (IS_UTF8_1(c)) \
00041 ascii++; \
00042 else if (IS_UTF8_I(c)) { \
00043 if (IS_UTF8_X(s[0])) \
00044 latin1++, s++; \
00045 else \
00046 errors++; \
00047 } \
00048 else if (IS_UTF8_2(c)) { \
00049 if (IS_UTF8_X(s[0])) \
00050 ucs2++, s++; \
00051 else \
00052 errors++; \
00053 } \
00054 else if (IS_UTF8_3(c)) { \
00055 if (IS_UTF8_X(s[0]) && IS_UTF8_X(s[1])) \
00056 ucs2++, s++, s++; \
00057 else \
00058 errors++; \
00059 } \
00060 else if (IS_UTF8_4(c)) { \
00061 if (IS_UTF8_X(s[0]) && IS_UTF8_X(s[1]) && IS_UTF8_X(s[2])) \
00062 ucs4++, s++, s++, s++; \
00063 else \
00064 errors++; \
00065 } \
00066 else if (IS_UTF8_5(c)) { \
00067 if (IS_UTF8_X(s[0]) && IS_UTF8_X(s[1]) && \
00068 IS_UTF8_X(s[2]) && IS_UTF8_X(s[3])) \
00069 ucs4++, s++, s++, s++, s++; \
00070 else \
00071 errors++; \
00072 } \
00073 else if (IS_UTF8_6(c)) { \
00074 if (IS_UTF8_X(s[0]) && IS_UTF8_X(s[1]) && \
00075 IS_UTF8_X(s[2]) && IS_UTF8_X(s[3]) && IS_UTF8_X(s[4])) \
00076 ucs4++, s++, s++, s++, s++, s++; \
00077 else \
00078 errors++; \
00079 } \
00080 else \
00081 errors++; \
00082 } \
00083 } while(0)
00084
00085 #endif