beatsaber-hook icon indicating copy to clipboard operation
beatsaber-hook copied to clipboard

Fix implementation of to_utf8 and to_utf16

Open StackDoubleFlow opened this issue 3 years ago • 1 comments

The current implementation of these functions do not properly convert between the unicode encodings and have caused bugs in the past. This new implementation makes use of std::codecvt and std::wstring_convert.

Although these specializations of codecvt are now deprecated in c++20, they will still work until there is a suitable replacement in the standard library, and as far as I know, such a thing does not exist yet.

It is recommended to use a proper library for this task. il2cpp has built in methods of performing this conversion, so it may be worth looking into that in the future.

StackDoubleFlow avatar Feb 05 '22 02:02 StackDoubleFlow

Consider using the string conversion functions available in typedefs-string.hpp, those functions perform the correct conversion and also are not deprecated. I do agree that the current implementations of to_utf8 and to_utf16 need some work, though, so I appreciate the step towards that.

sc2ad avatar Feb 08 '22 20:02 sc2ad