]> sjero.net Git - wget/blobdiff - src/iri.c
Show also the hostname in the locale when possible
[wget] / src / iri.c
index 1792ab6224fbd409ed9fcfce97778e10d60a8043..000f655037eeafb222d8078302551cee707104d1 100644 (file)
--- a/src/iri.c
+++ b/src/iri.c
@@ -185,6 +185,10 @@ do_conversion (iconv_t cd, char *in, size_t inlen, char **out)
       /* Incomplete or invalid multibyte sequence */
       if (errno == EINVAL || errno == EILSEQ)
         {
+          if (!invalid)
+            logprintf (LOG_VERBOSE,
+                      "Incomplete or invalide multibyte sequence encountered\n");
+
           invalid++;
           **out = *in;
           in++;
@@ -216,7 +220,7 @@ do_conversion (iconv_t cd, char *in, size_t inlen, char **out)
     return false;
 }
 
-/* Try to encode UTF-8 host to ASCII. Return the new domain on success or NULL
+/* Try to ASCII encode UTF-8 host. Return the new domain on success or NULL
    on error. */
 char *idn_encode (char *host)
 {
@@ -235,3 +239,22 @@ char *idn_encode (char *host)
   return new;
 }
 
+/* Try to decode an ASCII encoded host. Return the new domain in the locale on
+   success or NULL on error. */
+char *idn_decode (char *host)
+{
+  char *new;
+  int ret;
+
+  ret = idna_to_unicode_8zlz (host, &new, 0);
+  if (ret != IDNA_SUCCESS)
+    {
+      logprintf (LOG_VERBOSE, "idn_decode failed (%d): %s\n", ret,
+                 quote (idna_strerror (ret)));
+      return NULL;
+    }
+
+  return new;
+}
+
+