After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 691169 - Gimp fails to open files with UTF8 characters as filenames when started via Windows Explorer (e.g. the file context menu)
Gimp fails to open files with UTF8 characters as filenames when started via W...
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: General
2.8.4
Other Windows
: Normal normal
: 2.8
Assigned To: GIMP Bugs
GIMP Bugs
: 691822 724566 726480 (view as bug list)
Depends on: 522131
Blocks:
 
 
Reported: 2013-01-05 02:28 UTC by Moltres_rider
Modified: 2014-03-16 22:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
filename with japanese charset (58.00 KB, image/jpeg)
2013-01-05 02:31 UTC, Moltres_rider
  Details
load_localized_files_in_windows_2_8.patch (3.85 KB, patch)
2014-03-08 14:05 UTC, Hartmut Kuhse
none Details | Review
load_localized_files_in_windows_2_9.patch (3.89 KB, patch)
2014-03-08 14:06 UTC, Hartmut Kuhse
none Details | Review

Description Moltres_rider 2013-01-05 02:28:22 UTC
if you open a jpg that the filename is Japanese characters, Gimp will error out with "Opening '<filepath>?????????.jpg' failed. Could Not Open '<filepath>?????????.jpg' for reading: Invalid Argument"
Comment 1 Moltres_rider 2013-01-05 02:31:02 UTC
Created attachment 232805 [details]
filename with japanese charset
Comment 2 Michael Schumacher 2013-01-05 08:56:51 UTC
2.6.10 is obsolete, please try this with 2.8.2 and report back.
Comment 3 Moltres_rider 2013-01-05 20:29:44 UTC
same error occurs in Gimp 2.8.2
Comment 4 Michael Schumacher 2013-01-06 12:22:30 UTC
Works fine for me. Does this depend on something else, e.g. the locale of the system?
Comment 5 Moltres_rider 2013-01-06 13:02:43 UTC
no I just right click open with 'GNU Image Manipulation Program' and that error occurs EVERY TIME!!! no other program has this issue!!! and ONLY occurs with Gimp... if I rename it to only English letters, it works fine but NOT with Japanese characters...
Comment 6 Max Mustermann 2013-01-06 13:06:40 UTC
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find.

This bug often occurs on opening a file directly from the file manager if the filename has Non-ASCII characters. 
A workaround to open the file in GIMP until this bug is fixed is to use File/Open or dragging the file from your file manager into the GIMP window.

*** This bug has been marked as a duplicate of bug 522131 ***
Comment 7 Moltres_rider 2013-01-07 01:20:24 UTC
How is this a duplicate if bug 522131??? there is NOTHING similar regarding these two bugs!!! they are talking about commandline interfaces which I NEVER use!!! this is regarding open with 'GNU Image manipulation' program!!! no commandline ANYTHING here!!! read bug 522131 before you say this is a duplicate bug!!!
Comment 8 Michael Natterer 2013-01-07 01:29:06 UTC
Calm down. It is a duplicate. Using !!! and CAPS doesn't help
with taking you serious.

*** This bug has been marked as a duplicate of bug 522131 ***
Comment 9 Moltres_rider 2013-01-07 01:53:52 UTC
how??? there is nothing regarding right-clicking and opening with Gimp in that bug!
Comment 10 Mike Henning (drawoc) 2013-01-07 03:20:45 UTC
When you right click on something and choose to open with gimp, it causes windows to run the gimp with certain command line parameters.

This is a duplicate of bug 522131 because the issue is with how the gimp parses  those parameters.

Please close this.
Comment 11 Hib Eris 2013-01-07 06:54:44 UTC
Glib needs to be extended first (see bug 522131). After that, Gimp itself needs to be adapted to use new api from glib.
Comment 12 Michael Schumacher 2013-01-16 17:54:48 UTC
*** Bug 691822 has been marked as a duplicate of this bug. ***
Comment 13 Michael Schumacher 2013-05-28 19:52:01 UTC
Dependency on the glib bug is set, let's keep this as a reminder.
Comment 14 Michael Natterer 2014-02-18 10:00:38 UTC
*** Bug 724566 has been marked as a duplicate of this bug. ***
Comment 15 Hartmut Kuhse 2014-03-08 14:05:54 UTC
Created attachment 271310 [details] [review]
load_localized_files_in_windows_2_8.patch

I have a patch for that. The problem is, that 
 int main (int argc, char **argv)
just takes a char * as parameter. I think, differing from glibs gchar *, char is not utf-8, but ANSI.
The trick now is to make use of the entry point
 int wmain (int argc, wchar_t **argv)
where wchar_t is utf-16 coded.
This entry point is choosen, if (with a newer compiler) the linker
option -municode is activated.
In that entry function, the utf-16 chars are transformed to utf-8 format and
the standard main entry is called.
When loading the file, the filename must be recoded to a windows readable
coding.
The patches are for master (..._2_9) and for 2.8 (..._2_8).
Comment 16 Hartmut Kuhse 2014-03-08 14:06:21 UTC
Created attachment 271311 [details] [review]
load_localized_files_in_windows_2_9.patch
Comment 17 Mike Henning (drawoc) 2014-03-08 17:04:37 UTC
glib recently got functions to deal with this, and I'd prefer to use their solution because it's a bit cleaner.

There's an example of using it at the bottom of the description at:
https://developer.gnome.org/glib/unstable/glib-Commandline-option-parser.html#glib-Commandline-option-parser.description

This is currently only available in glib master, not in any release. It should be in glib 2.40 when that's released. I don't know if it would be okay to bump the glib requirement on 2.8 if the bump only applied for windows platforms.

We might want to copy the glib functions into gimp until we can depend on newer glib versions.
Comment 18 Michael Natterer 2014-03-08 21:35:12 UTC
We can't depend on 2.40 before it's even released :) Our policy (as in
pure policy in order to shut down infinite discussions) is that GIMP
master can depend on what is in debian testing.

IMO we should simply #if GLLIB_CHECK_VERSION() and use the new stuff,
so windows builds can be fixed by simply using newler GLib, in both
2.8 and master.

I actually have a patch stashed for that, let me push this to master.
Comment 19 Michael Natterer 2014-03-08 21:42:05 UTC
Fixed in master, please somebody test and report back before we
merge that to 2-8.

commit 774e064fbf4bc81add8d00182ee677175aa23c55
Author: Michael Natterer <mitch@gimp.org>
Date:   Sat Mar 8 22:38:27 2014 +0100

    Bug 691169 - Gimp fails to open files with UTF8 characters as filenames...
    
    ...when started via Windows Explorer (e.g. the file context menu)
    
    When built against GLib >= 2.39.90, use g_win32_get_command_line()
    and g_option_context_parse_strv() which handle all sorts of windows
    filename encodings properly.

 app/main.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Comment 20 Mike Henning (drawoc) 2014-03-09 00:42:01 UTC
I've tested mitch's commit, and it works correctly.
Comment 21 Mike Henning (drawoc) 2014-03-09 02:04:10 UTC
Tested and cherry-picked to 2.8.

commit 410ea91e226f01dc6723555534cf3650782aeb64
Author: Michael Natterer <mitch@gimp.org>
Date:   Sat Mar 8 22:38:27 2014 +0100

    Bug 691169 - Gimp fails to open files with UTF8 characters as filenames...
    
    ...when started via Windows Explorer (e.g. the file context menu)
    
    When built against GLib >= 2.39.90, use g_win32_get_command_line()
    and g_option_context_parse_strv() which handle all sorts of windows
    filename encodings properly.
    
    (cherry picked from commit 774e064fbf4bc81add8d00182ee677175aa23c55)
Comment 22 Michael Natterer 2014-03-16 22:43:07 UTC
*** Bug 726480 has been marked as a duplicate of this bug. ***