MCPcopy Create free account
hub / github.com/StereoKit/StereoKit / utf_insert_char

Function utf_insert_char

StereoKitC/libraries/unicode.cpp:288–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286///////////////////////////////////////////
287
288bool utf_insert_char(const char* buffer_utf8_start, size_t buffer_length, char* at_utf8, char32_t character) {
289 int32_t units = utf8_encode_units(character);
290
291 // Ensure there's enough memory in the string
292 if (buffer_length - (at_utf8 - buffer_utf8_start) < units) return false;
293
294 // Shift the string to make room for the new character
295 int32_t len = (int32_t)strlen(at_utf8);
296 for (int32_t i = len + units; i >= units; i--)
297 at_utf8[i] = at_utf8[i - units];
298
299 // And insert the new character
300 utf8_encode(at_utf8, character);
301 return true;
302}
303
304///////////////////////////////////////////
305

Callers 1

ui_input_gFunction · 0.85

Calls 5

utf8_encode_unitsFunction · 0.85
strlenFunction · 0.85
utf8_encodeFunction · 0.85
utf16_encode_unitsFunction · 0.85
utf16_encodeFunction · 0.85

Tested by

no test coverage detected