diff lib/protocols.c @ 582:5df46f79d9c1

2004-10-4 Brian Masney <masneyb@gftp.org> * 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
author masneyb
date Tue, 05 Oct 2004 00:13:09 +0000
parents 5dc685bf403e
children fa0838b22b14
line wrap: on
line diff
--- 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, _("<unknown>"), "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", _("<unknown>"), 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;