MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / readCodePoint

Function readCodePoint

src/OpenLoco/src/Localisation/Unicode.cpp:6–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4namespace 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}

Callers 3

enqueueTextFunction · 0.85
convertUnicodeToLocoFunction · 0.85
readStringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected