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

Christophe Fergeau cfergeau at redhat.com
Mon Oct 15 11:54:13 UTC 2018


Hey,

On Mon, Oct 15, 2018 at 07:26:12PM +0800, Qiu Wenbo wrote:
> Thank you. We can't use the same code path here. The code path of
> GApplication on Windows is different compared to Linux. To handle different
> file name encodings on Windows, GApplication will get its command line
> arguments through g_win32_get_command_line() which will return an arrary of
> UTF-8 encoded strings. But on Linux, GApplication simply get its command
> line  arguments through argv of the program's main() which is in encoded by
> current system locale. The only difference between g_option_context_parse()
> and g_option_context_parse_strv() is how they interpret their arguments. We
> need use g_option_context_parse_strv on Windows since it accept UTF-8
> encoded strings. And we should use the original code path to handle system
> locale encoded strings on Linux.

Looking at glib's code, on linux, I think we'd be getting locale encoded
strings with both methods on linux
( https://gitlab.gnome.org/GNOME/glib/blob/7c1f38b1c9d97519bf087a37a7d8c0a6e6bfdf18/gio/gapplication.c#L2385
and
https://gitlab.gnome.org/GNOME/glib/blob/fba8d7a48ad0f4455461162130c7f2eec9c4e363/glib/goption.c#L2688
- strv_mode is only used on Windows to convert between locale encoding
  and utf8).

Christophe
-------------- 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/3f55cfbd/attachment.sig>


More information about the virt-tools-list mailing list