Skip to content

TextSubtext() issue #3792

Answered by raysan5
DesLandysh asked this question in Q&A
Discussion options

You must be logged in to vote

@DesLandysh I'm afraid TextSubtext() does not consider UTF-8 strings but a plain byte array of data, so, Cyrillic characters are actually processed byte by byte, getting the equivalent character for every individual byte (or just crashing in the process)...

The solution would be getting the subtext character by character, considering that on UTF-8 some characters could imply more than one byte. raylib provides the following function for that:

int GetCodepointNext(const char *text, int *codepointSize);  // Get next codepoint in a UTF-8 encoded string

Here some code sample to move along a text buffer one character at a time, considering Unicode codepoints codified as UTF-8:

int currentCodep…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by DesLandysh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants