I want to change a UTF-8 character (which is in a gchar array), so it gets the value of the next character according to the standard. I’m using glib and I don’t see a function like that. I’m thinking of a possible solution, but it would take maybe more effort and surely it wouldn’t be the most efficient, as I don’t know too much about encodings. Is there any library that can do that? Googling didn’t help.
Share
This is essentially just add-and-carry modulo 64. Consider the bytes of the character as “digits”. You increment the last byte, and if it overflows, reset it to the smallest possible value, and increment the second-to-last byte.
For example, a simple increment:
An increment with single carry:
And an increment with double carry:
When you increment past the last character of a given size, you’ll need to go to the first character of the next size, which of course can’t be done in-place in the middle of a string.