[virt-tools-list] [PATCH virt-viewer] fix character encoding on Windows platform

Christophe Fergeau cfergeau at redhat.com
Mon Oct 15 10:13:31 UTC 2018


Hey,

For some reason, the patch did not get through so well (html maybe),
blank space was missing. I'm attaching a version which should be more
readable to this email. g_option_context_parse_strv documentation has
more details regarding the different with g_option_context_parse, I'd
add this to the commit log:

« On Windows, the strings are expected to be in UTF-8. This is in
contrast to g_option_context_parse() which expects them to be in the
system codepage, which is how they are passed as argv to main(). See
g_win32_get_command_line() for a solution. »

I'm not sure we need separate win32 and linux code paths here, have you
tried using g_option_context_parse_strv on linux, or did you keep code
this way just to be safe?

Thanks for the patch,

Christophe


On Mon, Oct 15, 2018 at 03:36:10PM +0800, 邱文博 wrote:
> virt-viewer can't handle encoding of its command line arguments correctly on Windows. As a simple test case, simply run
> 
> 
> 
>     remote-viewer -t "你好" spice://<target-host>:5900 
> 
> 
> on Windows and the titlebar will not display characters as we expect.
> 
> 
> From 5e52e3a2a292e9a663fc9ba6560603df5aca66b7 Mon Sep 17 00:00:00 2001 From: root <root at localhost.localdomain> Date: Mon, 15 Oct 2018 10:30:01 +0800 Subject: [PATCH] win32: fix command line encoding on windows platform ---  configure.ac          | 4 ++--  src/virt-viewer-app.c | 4 ++++  2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index d5eb258..08fc75e 100644 --- a/configure.ac +++ b/configure.ac @@ -13,8 +13,8 @@ m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])  AM_SILENT_RULES([yes])    # Keep these two definitions in agreement. -GLIB2_REQUIRED="2.38" -GLIB2_ENCODED_VERSION="GLIB_VERSION_2_38" +GLIB2_REQUIRED="2.40" +GLIB2_ENCODED_VERSION="GLIB_VERSION_2_40"    # Keep these two definitions in agreement.  GTK_REQUIRED="3.12" diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c index 2a88882..08fb234 100644 --- a/src/virt-viewer-app.c +++ b/src/virt-viewer-app.c @@ -1882,7 +1882,11 @@ virt_viewer_app_local_command_line (GApplication   *gapp,      g_option_context_add_group(context, spice_get_option_group());  #endif   +#ifndef G_OS_WIN32      if (!g_option_context_parse(context, &argc, args, &error)) { +#else +    if (!g_option_context_parse_strv(context, args, &error)) { +#endif          if (error != NULL) {              g_printerr(_("%s\n"), error->message);              g_error_free(error); --  2.17.2

> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list

-------------- next part --------------
From 26c16280368a54ca38bac945f2bd73a60d6adbbe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=82=B1=E6=96=87=E5=8D=9A?= <qiuwenbo at kylinos.com.cn>
Date: Mon, 15 Oct 2018 12:08:43 +0200
Subject: [virt-viewer] win32: fix command line encoding on windows platform

---
 configure.ac          | 4 ++--
 src/virt-viewer-app.c | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 9b52eb4..bfbf27d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,8 +13,8 @@ m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])
 AM_SILENT_RULES([yes])
 
 # Keep these two definitions in agreement.
-GLIB2_REQUIRED="2.38"
-GLIB2_ENCODED_VERSION="GLIB_VERSION_2_38"
+GLIB2_REQUIRED="2.40"
+GLIB2_ENCODED_VERSION="GLIB_VERSION_2_40"
 
 # Keep these two definitions in agreement.
 GTK_REQUIRED="3.12"
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index e0e6e63..15fc135 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -1851,7 +1851,11 @@ virt_viewer_app_local_command_line (GApplication   *gapp,
     g_option_context_add_group(context, spice_get_option_group());
 #endif
 
+#ifndef G_OS_WIN32
     if (!g_option_context_parse(context, &argc, args, &error)) {
+#else
+    if (!g_option_context_parse_strv(context, args, &error)) {
+#endif
         if (error != NULL) {
             g_printerr(_("%s\n"), error->message);
             g_error_free(error);
-- 
2.19.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20181015/4f492206/attachment.sig>


More information about the virt-tools-list mailing list