Skip to content

Fix opening files with Arabic names - #1532

Merged
ice0 merged 8 commits into
synfig:masterfrom
morevnaproject:fix_arabic_filenames
Jul 10, 2020
Merged

ice0 merged 8 commits into
synfig:masterfrom
morevnaproject:fix_arabic_filenames

Conversation

@morevnaproject

Copy link
Copy Markdown
Member

Closes #1517.

Previously we used Glib::locale_to_utf8() function, and it worked well for simple encodings (i.e. Russian). But for languages which use wide characters (UTF-16) (i.e. Arabic) this didn't worked. So now we use g_win32_get_command_line() function instead (https://developer.gnome.org/glib/stable/glib-Windows-Compatibility-Functions.html#g-win32-get-command-line).

But that was not enough. After adding g_win32_get_command_line() function the filename was converted properly, but file opening procedure still failing

After debugging I found that we have to do similar replacement for places where we access filesystem.
The solution is to use Glib's g_fopen() function instead of fopen() - https://people.gnome.org/~ryanl/glib-docs/glib-File-Utilities.html#g-fopen.

It is possible we need to use g_fopen() (and similar Glib's wrappers) in other places...

@morevnaproject

Copy link
Copy Markdown
Member Author

It is basically working now.

Still need to look for places where Glib::locale_to_utf8() function used and check where it should be replaced...

@morevnaproject
morevnaproject requested review from ice0 and rodolforg July 9, 2020 16:33
@morevnaproject
morevnaproject marked this pull request as ready for review July 9, 2020 16:33

@rodolforg rodolforg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no ways to test it because I don't use Windows at home (and I'm in home office due to the pandemic) and I don't have files in other languages like Russian and Arabic etc. :)

But the code seems fine, as long as the filenames are in UTF-8 according to the docs :)

My only concern here is that we increase the Glib dependence in synfig core.
By now, it was limited to GOption* for CLI tool and some remaining Glib::Threads.
Oh well, and some utf8<->locale stuff XD

And FileMonitor – heck that I don't want to handle by ourselves lol

@ice0

ice0 commented Jul 10, 2020

Copy link
Copy Markdown
Collaborator

@rodolforg agree.
But I think we can move all these things to the FileSystem class later, so switching dependencies will be a lot easier.

@morevnaproject

Copy link
Copy Markdown
Member Author

Please don’t merge it yet - I forgot to push one more commit. ^__^

@morevnaproject

Copy link
Copy Markdown
Member Author

Should be ready to merge now. ^__^

@ice0
ice0 merged commit f17715b into synfig:master Jul 10, 2020
@ice0

ice0 commented Jul 10, 2020

Copy link
Copy Markdown
Collaborator

Merged. Thank you!

@morevnaproject

Copy link
Copy Markdown
Member Author

Woops, I forgot to rebase. Sorry! ^__^"

@morevnaproject
morevnaproject deleted the fix_arabic_filenames branch July 10, 2020 15:40
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.

Synfig cannot open files with arabic filenames (Windows)

3 participants