| 152 | |
| 153 | |
| 154 | int UTF8Encoding::queryConvert(const unsigned char* bytes, int length) const |
| 155 | { |
| 156 | int n = _charMap[*bytes]; |
| 157 | int uc; |
| 158 | if (-n > length) |
| 159 | { |
| 160 | return n; |
| 161 | } |
| 162 | else |
| 163 | { |
| 164 | switch (n) |
| 165 | { |
| 166 | case -1: |
| 167 | return -1; |
| 168 | case -4: |
| 169 | case -3: |
| 170 | case -2: |
| 171 | if (!isLegal(bytes, -n)) return -1; |
| 172 | uc = *bytes & ((0x07 << (n + 4)) | 0x03); |
| 173 | break; |
| 174 | default: |
| 175 | return n; |
| 176 | } |
| 177 | while (n++ < -1) |
| 178 | { |
| 179 | uc <<= 6; |
| 180 | uc |= (*++bytes & 0x3F); |
| 181 | } |
| 182 | return uc; |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | |
| 187 | int UTF8Encoding::sequenceLength(const unsigned char* bytes, int length) const |
no outgoing calls
no test coverage detected