5c10b7bd9bb7701ff5a0f64b21992cee117bf9aa
 app/Makefile.am |  2 +-
 app/app.c       | 12 ++++++++++++
 app/main.c      | 42 +++++++++++++++++++++++++++++++++---------
 app/unique.c    |  6 +++++-
 4 files changed, 51 insertions(+), 11 deletions(-)

diff --git a/app/Makefile.am b/app/Makefile.am
index f506f08..b6ecb5c 100644
--- a/app/Makefile.am
+++ b/app/Makefile.am
@@ -92,7 +92,7 @@ framework_cocoa = -framework Cocoa
 endif
 
 if OS_WIN32
-win32_ldflags = -mwindows -Wl,--tsaware $(WIN32_LARGE_ADDRESS_AWARE)
+win32_ldflags = -municode -mwindows -Wl,--tsaware $(WIN32_LARGE_ADDRESS_AWARE)
 endif
 
 if USE_BINRELOC
diff --git a/app/app.c b/app/app.c
index 2023b8b..5e19684 100644
--- a/app/app.c
+++ b/app/app.c
@@ -259,8 +259,20 @@ app_run (const gchar         *full_prog_name,
 
       for (i = 0; filenames[i] != NULL; i++)
         {
+
+#ifdef G_OS_WIN32
+          gchar *locale_file;
+
+          locale_file = g_win32_locale_filename_from_utf8 (filenames[i]);
+
+          if (run_loop)
+            file_open_from_command_line (gimp, locale_file, as_new);
+
+          g_free (locale_file);
+#else
           if (run_loop)
             file_open_from_command_line (gimp, filenames[i], as_new);
+#endif /*G_OS_WIN32*/
         }
     }
 
diff --git a/app/main.c b/app/main.c
index b199447..887659a 100644
--- a/app/main.c
+++ b/app/main.c
@@ -68,13 +68,19 @@
  * use the API optionally only if present, though.
  */
 #define _WIN32_WINNT 0x0601
+#define _UNICODE
 #include <windows.h>
 #include <conio.h>
+#include <tchar.h>
 #endif
 
 #include "gimp-log.h"
 #include "gimp-intl.h"
 
+#ifdef G_OS_WIN32
+int              wmain                        (int           argc,
+                                               wchar_t     **argv);
+#endif
 
 static gboolean  gimp_option_fatal_warnings   (const gchar  *option_name,
                                                const gchar  *value,
@@ -278,6 +284,24 @@ static const GOptionEntry main_entries[] =
   { NULL }
 };
 
+#ifdef G_OS_WIN32
+int
+wmain (int    argc,
+       wchar_t **argv)
+{
+  gint   c;
+  gchar *g_argv[argc];
+
+  for (c = 0; c < argc; c++)
+    {
+      g_argv[c] = g_utf16_to_utf8 (argv[c], -1, NULL, NULL, NULL);
+    }
+
+  return main (argc, g_argv);
+}
+#endif
+
+
 int
 main (int    argc,
       char **argv)
@@ -288,15 +312,15 @@ main (int    argc,
   gchar          *basename;
   gint            i;
 
-#if defined (__GNUC__) && defined (_WIN64)
-  /* mingw-w64, at least the unstable build from late July 2008,
-   * starts subsystem:windows programs in main(), but passes them
-   * bogus argc and argv. __argc and __argv are OK, though, so just
-   * use them.
-   */
-  argc = __argc;
-  argv = __argv;
-#endif
+//#if defined (__GNUC__) && defined (_WIN64)
+//  /* mingw-w64, at least the unstable build from late July 2008,
+//   * starts subsystem:windows programs in main(), but passes them
+//   * bogus argc and argv. __argc and __argv are OK, though, so just
+//   * use them.
+//   */
+//  argc = __argc;
+//  argv = __argv;
+//#endif
 
 #ifdef G_OS_WIN32
   /* Reduce risks */
diff --git a/app/unique.c b/app/unique.c
index 3e00c2b..70892f2 100644
--- a/app/unique.c
+++ b/app/unique.c
@@ -203,8 +203,11 @@ gimp_unique_win32_open (const gchar **filenames,
           for (i = 0; filenames[i]; i++)
             {
               gchar *uri;
+              gchar *locale_filename;
 
-              uri = gimp_unique_filename_to_uri (filenames[i], cwd, &error);
+              locale_filename = g_win32_locale_filename_from_utf8(filenames[i]);
+
+              uri = gimp_unique_filename_to_uri (locale_filename, cwd, &error);
 
               if (uri)
                 {
@@ -214,6 +217,7 @@ gimp_unique_win32_open (const gchar **filenames,
 
                   SendMessage (window_handle,
                                WM_COPYDATA, (WPARAM) window_handle, (LPARAM) &copydata);
+                  g_free (locale_filename);
                 }
               else
                 {
