cf_string_decode_UTF8¶
Category: string
GitHub: cute_string.h
Decodes a single UTF8 character from the string as a UTF32 codepoint.
| Parameters | Description |
|---|---|
s |
The string. |
codepoint |
An int pointer to receive the decoded codepoint. |
Return Value¶
Returns pointer advanced past the decoded character (1 to 4 bytes).
Code Example¶
Decoding a UTF8 string one codepoint at a time.
int cp;
const char* tmp = my_string;
while (*tmp) {
tmp = cf_string_decode_UTF8(tmp, &cp);
DoSomethingWithCodepoint(cp);
}
Remarks¶
You can use this function in a loop to decode one codepoint at a time, where each codepoint represents a single UTF8 character. If the decoded codepoint is invalid then the "replacement character" 0xFFFD will be recorded instead.