| 4 | namespace OpenLoco::Localisation |
| 5 | { |
| 6 | utf32_t readCodePoint(const utf8_t** string) |
| 7 | { |
| 8 | utf32_t read = 0; |
| 9 | |
| 10 | const utf8_t* ptr = *string; |
| 11 | |
| 12 | if ((ptr[0] & 0b10000000) == 0) |
| 13 | { |
| 14 | read = ptr[0]; |
| 15 | *string += 1; |
| 16 | } |
| 17 | else if ((ptr[0] & 0b11100000) == 0b11000000) |
| 18 | { |
| 19 | read = ((ptr[0] & 0b11111) << 6) | (ptr[1] & 0b111111); |
| 20 | *string += 2; |
| 21 | } |
| 22 | else if ((ptr[0] & 0b11110000) == 0b11100000) |
| 23 | { |
| 24 | read = ((ptr[0] & 0b1111) << 12) | ((ptr[1] & 0b111111) << 6) | (ptr[2] & 0b111111); |
| 25 | *string += 3; |
| 26 | } |
| 27 | else if ((ptr[0] & 0b11111000) == 0b11110000) |
| 28 | { |
| 29 | read = ((ptr[0] & 0b111) << 18) | ((ptr[1] & 0b111111) << 12) | ((ptr[2] & 0b111111) << 6) |
| 30 | | (ptr[3] & 0b111111); |
| 31 | *string += 4; |
| 32 | } |
| 33 | |
| 34 | return read; |
| 35 | } |
| 36 | } |
no outgoing calls
no test coverage detected