diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2013-01-25 16:55:55 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-01-25 07:29:26 -0800 |
commit | ff5a8b0650a10b7b111f430bcc20b324d356a8ce (patch) | |
tree | adc1cb034ec1f9da68d1b6eee8812d02c7541bf1 /windows.c | |
parent | 7bb6108c340bee88b0b72cd92cce83398b3234ee (diff) | |
download | subsurface-ff5a8b0650a10b7b111f430bcc20b324d356a8ce.tar.gz |
windows.c: Add unicode support in subsurface_launch_for_uri()
subsurface_launch_for_uri() requires unicode support, using
ShellExecuteW() and also the passed UTF-8 buffer has to be translated
to UTF-16 beforehand. Once the ShellExecuteW() is done we release
the UTF-16 allocation.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'windows.c')
-rw-r--r-- | windows.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -300,10 +300,16 @@ void subsurface_command_line_exit(gint *argc, gchar ***argv) gboolean subsurface_launch_for_uri(const char* uri) { - if ((INT_PTR)ShellExecute(NULL, "open", uri, NULL, NULL, SW_SHOWNORMAL) > 32) - return TRUE; - g_message("ShellExecute failed for: %s", uri); - return FALSE; + gboolean ret = FALSE; + wchar_t *wuri = (wchar_t *)g_utf8_to_utf16(uri, -1, NULL, NULL, NULL); + if (wuri) { + if ((INT_PTR)ShellExecuteW(NULL, L"open", wuri, NULL, NULL, SW_SHOWNORMAL) > 32) + ret = TRUE; + free(wuri); + } + if (!ret) + g_message("ShellExecute failed for: %s", uri); + return ret; } /* check if we are running a newer OS version */ |