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

Function utf_remove_chars

StereoKitC/libraries/unicode.cpp:248–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246///////////////////////////////////////////
247
248bool utf_remove_chars(char* at_utf8, int32_t count) {
249 if (!at_utf8) return false;
250
251 size_t remove = 0;
252 char* curr = at_utf8;
253 for (size_t i = 0; i < count; i++) {
254 if (*curr == '\0') break;
255 else if ((*curr & 0b10000000) == 0 ) remove += 1;
256 else if ((*curr & 0b11100000) == 0b11000000) remove += 2;
257 else if ((*curr & 0b11110000) == 0b11100000) remove += 3;
258 else if ((*curr & 0b11111000) == 0b11110000) remove += 4;
259 curr = at_utf8 + remove;
260 }
261
262 size_t len = strlen(at_utf8)+1;
263 size_t copy = len < remove ? remove : len;
264 for (size_t i = 0; i < copy; i++)
265 at_utf8[i] = at_utf8[i + remove];
266
267 return remove != 0;
268}
269
270///////////////////////////////////////////
271

Callers 1

ui_input_gFunction · 0.85

Calls 1

strlenFunction · 0.85

Tested by

no test coverage detected