# HG changeset patch # User masneyb # Date 1096935189 0 # Node ID 5df46f79d9c1ba1118063943fc4c0917b75f9d78 # Parent abcb6713b6b8b86264e2425402d8b0cfb19449a0 2004-10-4 Brian Masney * lib/protocols.c (gftp_string_from_utf8,gftp_string_to_utf8) - added more printf() functions whenever there is a problem converting a string * src/gtk/gtkui_transfer.c (gftpui_ask_transfer) - make sure the filename that is to be displayed to the user is encoded in UTF8 diff -r abcb6713b6b8 -r 5df46f79d9c1 ChangeLog --- a/ChangeLog Mon Oct 04 15:31:25 2004 +0000 +++ b/ChangeLog Tue Oct 05 00:13:09 2004 +0000 @@ -1,3 +1,10 @@ +2004-10-4 Brian Masney + * lib/protocols.c (gftp_string_from_utf8,gftp_string_to_utf8) - added + more printf() functions whenever there is a problem converting a string + + * src/gtk/gtkui_transfer.c (gftpui_ask_transfer) - make sure the + filename that is to be displayed to the user is encoded in UTF8 + 2004-10-3 Brian Masney * lib/protocols.c (gftp_string_to_utf8) - if the current string is already in UTF-8, always return NULL, even if the iconv module is @@ -2923,7 +2930,7 @@ * cvsclean - added this script - * *.[ch] - added $Id: ChangeLog,v 1.340 2004/10/04 02:07:33 masneyb Exp $ tags + * *.[ch] - added $Id: ChangeLog,v 1.341 2004/10/05 00:13:09 masneyb Exp $ tags * debian/* - updated files from Debian maintainer diff -r abcb6713b6b8 -r 5df46f79d9c1 lib/protocols.c --- a/lib/protocols.c Mon Oct 04 15:31:25 2004 +0000 +++ b/lib/protocols.c Tue Oct 05 00:13:09 2004 +0000 @@ -451,8 +451,15 @@ if (g_utf8_validate (str, -1, NULL)) return (NULL); else if (request->iconv_initialized) - return (g_convert_with_iconv (str, -1, request->iconv, &bread, &bwrite, - &error)); + { + ret = g_convert_with_iconv (str, -1, request->iconv, &bread, &bwrite, + &error); + if (ret == NULL) + printf (_("Error converting string '%s' from character set %s to character set %s: %s\n"), + str, _(""), "UTF-8", error->message); + + return (ret); + } gftp_lookup_request_option (request, "remote_charsets", &tempstr); if (*tempstr == '\0') @@ -480,6 +487,9 @@ if ((ret = g_convert_with_iconv (str, -1, request->iconv, &bread, &bwrite, &error)) == NULL) { + printf (_("Error converting string '%s' from character set %s to character set %s: %s\n"), + str, cur_charset, "UTF-8", error->message); + g_iconv_close (request->iconv); request->iconv = NULL; continue; @@ -507,9 +517,20 @@ if (request == NULL) return (NULL); - if (request->iconv_initialized) - return (g_convert_with_iconv (str, -1, request->iconv, &bread, &bwrite, - &error)); + /* If the string isn't in UTF-8 format, assume it is already in the current + locale... */ + if (!g_utf8_validate (str, -1, NULL)) + return (NULL); + else if (request->iconv_initialized) + { + ret = g_convert_with_iconv (str, -1, request->iconv, &bread, &bwrite, + &error); + if (ret == NULL) + printf (_("Error converting string '%s' from character set %s to character set %s: %s\n"), + str, "UTF-8", _(""), error->message); + + return (ret); + } gftp_lookup_request_option (request, "remote_charsets", &tempstr); if (*tempstr == '\0') @@ -537,6 +558,9 @@ if ((ret = g_convert_with_iconv (str, -1, request->iconv, &bread, &bwrite, &error)) == NULL) { + printf (_("Error converting string '%s' from character set %s to character set %s: %s\n"), + str, "UTF-8", cur_charset, error->message); + g_iconv_close (request->iconv); request->iconv = NULL; continue; diff -r abcb6713b6b8 -r 5df46f79d9c1 src/gtk/gtkui_transfer.c --- a/src/gtk/gtkui_transfer.c Mon Oct 04 15:31:25 2004 +0000 +++ b/src/gtk/gtkui_transfer.c Tue Oct 05 00:13:09 2004 +0000 @@ -206,7 +206,7 @@ gftpui_ask_transfer (gftp_transfer * tdata) { char *dltitles[4], *add_data[4] = { NULL, NULL, NULL, NULL }, - tempstr[50], temp1str[50], *pos; + tempstr[50], temp1str[50], *pos, *utf8_file; GtkWidget * dialog, * tempwid, * scroll, * hbox; gftp_file * tempfle; GList * templist; @@ -290,7 +290,9 @@ len = strlen (tdata->toreq->directory); if (strncmp (pos, tdata->toreq->directory, len) == 0) pos = tempfle->destfile + len + 1; - add_data[0] = pos; + + utf8_file = gftp_string_to_utf8 (tdata->toreq, pos); + add_data[0] = utf8_file != NULL ? utf8_file : pos; gftp_get_transfer_action (tdata->fromreq, tempfle); switch (tempfle->transfer_action) @@ -315,6 +317,9 @@ i = gtk_clist_append (GTK_CLIST (tdata->clist), add_data); gtk_clist_set_row_data (GTK_CLIST (tdata->clist), i, tempfle); + + if (utf8_file != NULL) + g_free (utf8_file); } gtk_clist_select_all (GTK_CLIST (tdata->clist));