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

Unicode support #44

Open
VortexCoyote opened this issue Aug 14, 2021 · 3 comments
Open

Unicode support #44

VortexCoyote opened this issue Aug 14, 2021 · 3 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@VortexCoyote
Copy link
Owner

Loading files with unicode currently crashes the editor. Investigate how we can support this format

@VortexCoyote VortexCoyote added bug Something isn't working enhancement New feature or request labels Aug 14, 2021
@JaanJah
Copy link
Contributor

JaanJah commented Aug 15, 2021

I looked into this and found out that we probably have to load in another font and add a japanese/other glyph ranges to support more unicode characters.

Ref: https://github.com/ocornut/imgui/blob/master/docs/FONTS.md#font-loading-instructions

@UnnamedOrange
Copy link
Contributor

It seems that the imgui open file dialog uses UTF-8 as its coding, though the type std::string or const char* is used. However, in Windows const char* means ANSI, which is not the same as UTF-8. An experiment is shown below. Change:

std::ifstream chartFile(InPath);

To:

	std::ifstream chartFile{std::filesystem::path(reinterpret_cast<const char8_t*>(InPath.c_str()))}; // Regard InPath as UTF-8.

(To support char8_t, use C++20.) This makes the constructor of ifstream work, while the former one will throw a "File not found!".

Note that there are more codes to be modified.

@UnnamedOrange
Copy link
Contributor

Sample of InPath:

C:\Users\username\Desktop\测试\516517 DJ Sharpnel - Over the Fullereneshift

测试 in the path corrupts the routine, while a path in pure English will not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants