aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-04-27 15:19:28 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-04-27 15:19:28 +0000
commit877f16e5a5222a13e69ab34778436c49c5c9a991 (patch)
tree0b09c64b35544f1fa2f422fc51e47be33b63e8e9
parentfbe1fa9dcc5554beaad0394ce453812b6c698cf6 (diff)
IDN: Gisle Vanem made the win32 version handle a missing CHARSET environment
and then figure it out with a suitable windows call.
-rw-r--r--lib/easy.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/easy.c b/lib/easy.c
index fc3f96963..a1289d45b 100644
--- a/lib/easy.c
+++ b/lib/easy.c
@@ -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;