Skip to content

sappend_UTF8

Category: string
GitHub: cute_string.h


Appends a UTF32 codepoint (as uint32_t) encoded as UTF8 onto the string.

#define sappend_UTF8(s, codepoint) cf_string_append_UTF8(s, codepoint)
Parameters Description
s The string. Can be NULL.
codepoint An int codepoint in UTF32 form.

Code Example

Example of suggested way to use this function within a loop.

sdyna char s = NULL;
while (has_codepoint()) {
    sappend_UTF8(s, get_codepoint());
}
sfree(s);

Remarks

The UTF8 bytes are appended onto the string.

Each UTF32 codepoint represents a single character. Each character can be encoded from 1 to 4 bytes. Therefor, this function will push 1 to 4 bytes onto the string.

If an invalid codepoint is found the "replacement character" 0xFFFD will be appended instead, which looks like question mark inside of a dark diamond.

cf_decode_UTF16
cf_decode_UTF8