dfranx / ImFileDialog

A file dialog library for Dear ImGui
MIT License
521 stars 61 forks source link

Unicode support for file / folder result #4

Closed alwendya closed 3 years ago

alwendya commented 3 years ago

Hi, first this work is amazing ! I'm French and using special character in filename like 'é' î' ... When I open a file picker, the file name are not shown in totality, part are truncated where the special character is located : Exemple : image Here the folder name is '§Rangement à trier' and it shown '?rangement ?rier'. I hope you can fix this because this file/folder browser is great. If I can be of any help...

Grégory

alwendya commented 3 years ago

I managed to make a work around : I'm putting my modified file attached to this post for information and I am well aware that's only working for windows but it give an hint of the way to proceed (And I don't know if the same happen from linux users for an example)...

I'm using these 3 function when text rendering happen or conversion between string/wstring using begin()/end() method which is unaware of utf8 string :

Keep going ... Grégory PS: I try my best to write in english, I hope I'm understandable...

dfranx commented 3 years ago

Thank you for reporting this!

This should now be fixed with commit afbcf44 . I used std::filesystem::path's u8string() method to get the UTF-8 encoded string. Dear ImGui should now be able to properly display the folder/file names.

PS: if you want to obtain the bookmarked directories, use the method GetFavorites(). You can then save the contents of the returned variable however you want to (it returns a vector of UTF-8 encoded std::strings). To add the bookmark, call AddFavorite() method. Both methods use UTF-8 encoded strings