[Spice-devel] [patch]spice-gtk: encoding problem when drag a file from client to guest
Marc-André Lureau
mlureau at redhat.com
Mon Feb 17 05:27:28 PST 2014
----- Original Message -----
> On Mon, Feb 17, 2014 at 8:47 PM, Marc-André Lureau <mlureau at redhat.com>
> wrote:
> > Hi
> >
> > ----- Original Message -----
> >> hi, here's my environment:
> >> client: win7(default encoding is GBK)
> >> guest the same with client
> >> spice-gtk-0.23d
> >>
> >> a file in guest with a name of Chinese
> >> the file name is wrong when drag it to guest desktop
> >> (I think Japanese and Korean have the same problem )
> >>
> >> the following is my patch to " spice-gtk-0.23/gtk/channel-main.c"
> >>
> >> Regards
> >>
> >> --- spice-gtk-0.23/gtk/channel-main.c 2014-02-06 19:08:07.000000000 +0800
> >> +++ spice-gtk-0.23_modified/gtk/channel-main.c 2014-02-17
> >> 20:12:55.037816310
> >> +0800
> >> @@ -2786,8 +2786,10 @@
> >>
> >> /* File name */
> >> basename = g_file_get_basename(file);
> >> - g_key_file_set_string(keyfile, "vdagent-file-xfer", "name", basename);
> >
> > From glib API reference, I understand basename is a byte string of
> > unspecified encoding.
> >
> unspecified encoding == "utf-8" or unspecified encoding == locale encoding?
> do you mean locale encoding?
>From API doc, https://developer.gnome.org/gio/stable/GFile.html#g-file-get-basename :
"
The base name is a byte string (not UTF-8). It has no defined encoding or rules other than it may not contain zero bytes. If you want to use filenames in a user interface you should use the display name that you can get by requesting the G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME attribute with g_file_query_info().
"
> >> + gchar *basename_loc = g_locale_from_utf8(basename, -1, NULL, NULL,
> >> NULL);
> >
> > So this is probably wrong. You should also check for errors.
>
> yeah, actually, i use g_convert(basename, -1, "gbk", "utf-8", ...) to
> get a right result
> but I don't think it's a general case, so patch it with
> g_locale_from_utf8(...)
> I'll keep testing to Confirm the problem
>
> > Instead, I think we should use g_file_info_get_display_name()
> thx, I'd try
> >> + g_key_file_set_string(keyfile, "vdagent-file-xfer", "name",
> >> basename_loc);
> >> g_free(basename);
> >> + g_free(basename_loc);
> >> /* File size */
> >> g_key_file_set_uint64(keyfile, "vdagent-file-xfer", "size",
> >> task->file_size);
> >>
> >
> > Can you send patches using git-send-email (inline by default) or as
> > attachments?
>
> sorry, it's my first time to send a patch in mail list, thank you for Remind
> :)
Great! Welcome! Feel free to join and ask questions on spice irc channel if you need further help.
> > thanks
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>
More information about the Spice-devel
mailing list