105 { |
105 { |
106 return GB(c, 6, 2) == 2; |
106 return GB(c, 6, 2) == 2; |
107 } |
107 } |
108 |
108 |
109 /** |
109 /** |
110 * Retrieve the (partial) length of the previous UNICODE character |
110 * Retrieve the previous UNICODE character in an UTF-8 encoded string. |
111 * in an UTF-8 encoded string. |
111 * @param s char pointer pointing to (the first char of) the next character |
112 * @param s char pointer pointing to the first char of the next character |
112 * @returns a pointer in 's' to the previous UNICODE character's first byte |
113 * @returns the decoded length in bytes (size) of the UNICODE character |
113 * @note The function should not be used to determine the length of the previous |
114 * that was just before the one where 's' is pointing to |
114 * encoded char because it might be an invalid/corrupt start-sequence |
115 * @note If 's' is not pointing to the first byte of the next UNICODE character |
|
116 * only a partial length of the sequence will be returned. |
|
117 * For example given this sequence: 0xE3 0x85 0x80, 0xE3 0x81 0x9E |
|
118 * 1. 's' is pointing to the second 0xE3, return value is 3 |
|
119 * 2. 's' is pointing to 0x80, return value is 2. |
|
120 * So take care with the return values of this function. To get the real length |
|
121 * for an (invalid) sequence, pass the string offset of this function's return |
|
122 * value to Utf8EncodedCharLen() or Utf8Decode() |
|
123 */ |
115 */ |
124 static inline size_t Utf8PrevCharLen(const char *s) |
116 static inline char *Utf8PrevChar(const char *s) |
125 { |
117 { |
126 size_t len = 1; |
118 const char *ret = s; |
127 while (IsUtf8Part(*--s)) len++; |
119 while (IsUtf8Part(*--ret)); |
128 return len; |
120 return (char*)ret; |
129 } |
121 } |
130 |
122 |
131 |
123 |
132 static inline bool IsPrintable(WChar c) |
124 static inline bool IsPrintable(WChar c) |
133 { |
125 { |