thpatch / thcrap

Touhou Community Reliant Automatic Patcher
https://www.thpatch.net
The Unlicense
565 stars 42 forks source link

Use utf8_to_utf[16/32]_masking as general string conversion function #212

Closed 32th-System closed 1 year ago

32th-System commented 1 year ago

I am not really sure why 3 different ways were added to convert UTF-8 strings to UTF-16 strings. But out of the ones that were added, masking was always the fastest in all of my experiments. I therefore decided: (on a separate branch cause I didn't want to upset anyone)

1) masking should be the one and only utf8_to_utf16 function 2) a similar function should also be used for UTF-32 3) these functions should be used everywhere, and mbrtoc16 and mbrtoc32 should be avoided, since these functions are unimplemented in Wine

And the 3rd point is the whole reason I did any of this to begin with.

This would fix the issue where Wine users are unable to have patches that use UTF-16 strings in any of their options fields and would finally allow me to fix hint files in th10

The commit in which the 3 utf8_to_utf16 functions were introduced is https://github.com/thpatch/thcrap/commit/d796da6de2a8bd39ee94899392708d01ed1eae28