| 379 | */ |
| 380 | |
| 381 | static Boolean isLegalUTF8(const UTF8 *source, int length) { |
| 382 | UTF8 a; |
| 383 | const UTF8 *srcptr = source+length; |
| 384 | switch (length) { |
| 385 | default: return false; |
| 386 | /* Everything else falls through when "true"... */ |
| 387 | case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; |
| 388 | case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; |
| 389 | case 2: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false; |
| 390 | |
| 391 | switch (*source) { |
| 392 | /* no fall-through in this inner switch */ |
| 393 | case 0xE0: if (a < 0xA0) return false; break; |
| 394 | case 0xED: if (a > 0x9F) return false; break; |
| 395 | case 0xF0: if (a < 0x90) return false; break; |
| 396 | case 0xF4: if (a > 0x8F) return false; break; |
| 397 | default: if (a < 0x80) return false; |
| 398 | } |
| 399 | |
| 400 | case 1: if (*source >= 0x80 && *source < 0xC2) return false; |
| 401 | } |
| 402 | if (*source > 0xF4) return false; |
| 403 | return true; |
| 404 | } |
| 405 | |
| 406 | /* --------------------------------------------------------------------- */ |
| 407 |
no outgoing calls
no test coverage detected