Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix implementation of to_utf8 and to_utf16 #123

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

StackDoubleFlow
Copy link

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.

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.
@sc2ad
Copy link
Owner

sc2ad commented Feb 8, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants