There are some other functions (UTF8_total_codepoints() to get the total number of codepoints in a string, UTF8_backspace() to get the length of a string after backspacing one character, and UTF8_peek_next() as a slightly less fancy version of UTF8_next()), but more functions could always be added if we need them.
This allows us to replace utfcpp (utf8::unchecked) - which is also done in this PR - and also fix some less-than-ideal code:
Some places had to resort to ignoring UTF-8 (next_wrap) or using UCS-4→UTF-8 functions (VFormat had to use PHYSFS ones, and one other place had four lines of code including a std::back_inserter just for one character)
The iterator stuff is kinda confusing and verbose anyway.
The reason why I'm doing this now is also because my next button glyphs PR will most likely need it to encode the characters used for the button glyphs (and because next_wrap being incomplete might matter for localization).
Legal Stuff:
By submitting this pull request, I confirm that...
[x] My changes may be used in a future commercial release of VVVVVV
[x] I will be credited in a CONTRIBUTORS file and the "GitHub Friends"
section of the credits for all of said releases, but will NOT be compensated
for these changes
Changes:
This adds a small library I wrote to handle UTF-8.
Usage is meant to be as simple as possible - see for example decoding a UTF-8 string:
Or encoding a single codepoint to add it to a string:
There are some other functions (
UTF8_total_codepoints()
to get the total number of codepoints in a string,UTF8_backspace()
to get the length of a string after backspacing one character, andUTF8_peek_next()
as a slightly less fancy version ofUTF8_next()
), but more functions could always be added if we need them.This allows us to replace utfcpp (utf8::unchecked) - which is also done in this PR - and also fix some less-than-ideal code:
next_wrap
) or using UCS-4→UTF-8 functions (VFormat had to use PHYSFS ones, and one other place had four lines of code including astd::back_inserter
just for one character)The reason why I'm doing this now is also because my next button glyphs PR will most likely need it to encode the characters used for the button glyphs (and because
next_wrap
being incomplete might matter for localization).Legal Stuff:
By submitting this pull request, I confirm that...
CONTRIBUTORS
file and the "GitHub Friends" section of the credits for all of said releases, but will NOT be compensated for these changes