-
Notifications
You must be signed in to change notification settings - Fork 35
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
A better way to implement IMGUI::filesystem. #13
Comments
First of all, thanks for your feedback!
Well, this is documented in README_FIRST.txt and it shouldn't happen if you define in your Project Settings DIRENT_USES_UTF8_CHARS. Have you tried it ?
Thanks for this tip, I think I'll add it in next commit, since many people compile the cpp files of the addons by themselves to include them as stand-alone (without using the provided imgui_user.h imgui_user.inl), and I'm recently making them compilable this way too, wherever possible. Added.
Thanks, but I'd rather not depend on c++17 and/or boost.
It helped. Thank you! |
Added windows.h to make it easier to compile as stand-alone. See #13.
Actually, on a second thought:
This shouldn't happen... the paths with non-ASCII name should be converted to short paths... this is very strange... ... maybe I could add your workaround... if it must be explicitly enabled I think it's acceptable. Having some other point of view on this could be helpful... I'm on Linux and I cannot test it on Windows (other than under Wine,and it seems to work there (but I didn't test it too much)). |
Hi Flix. I tried to define As I know, the header Actually, all things we should do are making a right form directory or file path and passing it to our C++ compiler to list or get it's content. But the path forms are different on Windows and Unix-like system. So it's hard to do this. Because you want write some codes like: #if is_windows
#elif is_unix_like
#end
The following is my directory structure(font file 10M+): Note: you should use UTF-8 for final displaying becase IMGUI only recognize UTF-8 encoding for chinese fonts(If I'm wrong, tell me). |
In the meantime, in a recent commit I've:
I think this is what most Window users expect. |
[Just an idea] Have you tried to explicitly set your C and C++ locale to your native locale (it should be simplified-chinese) and see if with these settings you can have correct automatic conversions to the GB2312 encoding (so that you can remove the boost dependency)? Not sure at all if this works, but maybe if you define something like: #include <locale.h> // for the C locale
#include <locale> // for the C++ locale
#include <stdio.h> //fprintf
void main() {
// This sets your default C locale to native and displays it (so that you can check it):
fprintf(stderr,"setlocale(LC_ALL, \"\")=%s\n",setlocale(LC_ALL, "")); // default is setlocale(LC_ALL, "C") AFAIK and it's NOT localized...
// Same for the C++ locale (I suspect this changes the C locale as well...)
std::locale::global(std::locale(""));
}
then it could work. |
My operating system is Windows 10 64-bits and the system's language is chinese.
Here I have a folder, its cotents show like these:
When I use the IMGUIFs::Dialog and enter this folder, I got:
It seems that:
Both
1
and2
are caused by using of APIscandir
. I hadn't known this API before. But when I debug into theDirectory::GetFiles
andDirectory::GetDirectories
I make sure it is the causing reason.(By the way, I got compiler error when I compiler filesystem.cpp under Visual Studio 2015 X64 model. I fix it by adding
#ifdef _WIN32 #include <Windows.h> #endif
piror to the first include directive in this file.)For myself, I modified the filesystem.cpp to resolve this as following:
Add supporting header and API:
Subsitute the code fragments in
Directory::GetFiles or Directory::GetDirectorys
by:The result:
Hope this helps. ------ Leslie.
The text was updated successfully, but these errors were encountered: