equal
deleted
inserted
replaced
79 |
79 |
80 /** Return the length of a UTF-8 encoded character. |
80 /** Return the length of a UTF-8 encoded character. |
81 * @param c Unicode character. |
81 * @param c Unicode character. |
82 * @return Length of UTF-8 encoding for character. |
82 * @return Length of UTF-8 encoding for character. |
83 */ |
83 */ |
84 static inline size_t Utf8CharLen(WChar c) |
84 static inline int8 Utf8CharLen(WChar c) |
85 { |
85 { |
86 if (c < 0x80) return 1; |
86 if (c < 0x80) return 1; |
87 if (c < 0x800) return 2; |
87 if (c < 0x800) return 2; |
88 if (c < 0x10000) return 3; |
88 if (c < 0x10000) return 3; |
89 if (c < 0x110000) return 4; |
89 if (c < 0x110000) return 4; |
98 * char should be the first byte of the UTF-8 encoding. If not, or encoding |
98 * char should be the first byte of the UTF-8 encoding. If not, or encoding |
99 * is invalid, return value is 0 |
99 * is invalid, return value is 0 |
100 * @param c char to query length of |
100 * @param c char to query length of |
101 * @return requested size |
101 * @return requested size |
102 */ |
102 */ |
103 static inline size_t Utf8EncodedCharLen(char c) |
103 static inline int8 Utf8EncodedCharLen(char c) |
104 { |
104 { |
105 if (GB(c, 3, 5) == 0x1E) return 4; |
105 if (GB(c, 3, 5) == 0x1E) return 4; |
106 if (GB(c, 4, 4) == 0x0E) return 3; |
106 if (GB(c, 4, 4) == 0x0E) return 3; |
107 if (GB(c, 5, 3) == 0x06) return 2; |
107 if (GB(c, 5, 3) == 0x06) return 2; |
108 if (GB(c, 7, 1) == 0x00) return 1; |
108 if (GB(c, 7, 1) == 0x00) return 1; |