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

Function convertUnicodeToLoco

src/OpenLoco/src/Localisation/Conversion.cpp:209–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207 }
208
209 uint8_t convertUnicodeToLoco(utf32_t unicode)
210 {
211 auto tableLookup = [unicode](auto&& table) {
212 auto it = std::ranges::lower_bound(
213 table,
214 unicode,
215 {},
216 &EncodingConvertEntry::unicode);
217
218 // Handle edge case where iterator is valid, but mismatches the input
219 return it != table.end() && it->unicode == unicode ? it : table.end();
220 };
221
222 // Extended Latin characters that are supported by Locomotion as-is
223 if (auto it = tableLookup(kUnicodeToLocoTable); it != kUnicodeToLocoTable.end())
224 {
225 return it->locoCode;
226 }
227
228 // Remove diacritics from letters that don't have an associated glyph yet
229 if (auto it = tableLookup(kUnicodeTemporaryStrip); it != kUnicodeTemporaryStrip.end())
230 {
231 return it->locoCode;
232 }
233
234 // Basic Latin characters
235 if (unicode < 256)
236 {
237 return static_cast<uint8_t>(unicode);
238 }
239
240 return LocoChar::replacement_character;
241 }
242
243 std::string convertUnicodeToLoco(const std::string& unicodeString)
244 {

Callers 10

prepareDrawFunction · 0.85
openFunction · 0.85
prepareDrawFunction · 0.85
drawFunction · 0.85
drawScrollFunction · 0.85
processFileForLoadSaveFunction · 0.85
processFileForDeleteFunction · 0.85
enqueueTextFunction · 0.85
enumerateLanguagesFunction · 0.85
readStringFunction · 0.85

Calls 2

readCodePointFunction · 0.85
endMethod · 0.45

Tested by

no test coverage detected