| 286 | /////////////////////////////////////////// |
| 287 | |
| 288 | bool 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 |
no test coverage detected