| 34 | }; |
| 35 | |
| 36 | uint32_t NextChar(const char** str) { |
| 37 | uint32_t c = 0; |
| 38 | int i = 0; |
| 39 | const char* s = *str; |
| 40 | |
| 41 | // Edge-case for termination, see doc for behavior |
| 42 | // Not so pretty perhaps |
| 43 | if (*s == 0) { |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | do { |
| 48 | c <<= 6; |
| 49 | c += (uint8_t)(*s); |
| 50 | ++s; |
| 51 | ++i; |
| 52 | } while (*s && (*s & 0xc0) == 0x80); |
| 53 | |
| 54 | c -= offsets[i-1]; |
| 55 | *str = s; |
| 56 | return c; |
| 57 | } |
| 58 | |
| 59 | uint32_t ToUtf8(uint16_t chr, char* buf) |
| 60 | { |
no outgoing calls