| 396 | */ |
| 397 | |
| 398 | static Boolean isLegalUTF8(const UTF8 *source, int length) { |
| 399 | UTF8 a; |
| 400 | const UTF8 *srcptr = source+length; |
| 401 | switch (length) { |
| 402 | default: return false; |
| 403 | /* Everything else falls through when "true"... */ |
| 404 | case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; |
| 405 | case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; |
| 406 | case 2: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; |
| 407 | |
| 408 | switch (*source) { |
| 409 | /* no fall-through in this inner switch */ |
| 410 | case 0xE0: if (a < 0xA0) return false; break; |
| 411 | case 0xED: if (a > 0x9F) return false; break; |
| 412 | case 0xF0: if (a < 0x90) return false; break; |
| 413 | case 0xF4: if (a > 0x8F) return false; break; |
| 414 | default: if (a < 0x80) return false; |
| 415 | } |
| 416 | |
| 417 | case 1: if (*source >= 0x80 && *source < 0xC2) return false; |
| 418 | } |
| 419 | if (*source > 0xF4) return false; |
| 420 | return true; |
| 421 | } |
| 422 | |
| 423 | /* --------------------------------------------------------------------- */ |
| 424 |
no outgoing calls
no test coverage detected