]> granicus.if.org Git - curl/commitdiff
IDN: Gisle Vanem made the win32 version handle a missing CHARSET environment
authorDaniel Stenberg <daniel@haxx.se>
Tue, 27 Apr 2004 15:19:28 +0000 (15:19 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 27 Apr 2004 15:19:28 +0000 (15:19 +0000)
and then figure it out with a suitable windows call.

lib/easy.c

index fc3f9696365d768019ac8f4be80a14cebaf79bec..a1289d45b51f86fd4f8757e4f46ac1a675b8336d 100644 (file)
@@ -66,7 +66,7 @@
 #include <sys/select.h>
 #endif
 
-#endif
+#endif  /* WIN32 ... */
 
 #include "urldata.h"
 #include <curl/curl.h>
@@ -138,6 +138,28 @@ static CURLcode win32_init(void) { return CURLE_OK; }
 static void win32_cleanup(void) { }
 #endif
 
+#ifdef USE_LIBIDN
+/*
+ * Initialise use of IDNA library.
+ * It falls back to ASCII if $CHARSET isn't defined. This doesn't work for
+ * idna_to_ascii_lz().
+ */
+static void idna_init (void)
+{
+#ifdef WIN32
+  char buf[60];
+  UINT cp = GetACP();
+
+  if (!getenv("CHARSET") && cp > 0) {
+    snprintf(buf, sizeof(buf), "CHARSET=cp%u", cp);
+    putenv(buf);
+  }
+#else
+  /* to do? */
+#endif
+}
+#endif  /* USE_LIBIDN */
+
 /* true globals -- for curl_global_init() and curl_global_cleanup() */
 static unsigned int  initialized = 0;
 static long          init_flags  = 0;
@@ -163,6 +185,10 @@ CURLcode curl_global_init(long flags)
     return CURLE_FAILED_INIT;
 #endif
 
+#ifdef USE_LIBIDN
+  idna_init();
+#endif
+
   initialized = 1;
   init_flags  = flags;