beatsaber-hook
beatsaber-hook copied to clipboard
Fix implementation of to_utf8 and to_utf16
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.
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.