--- iconv_module.c.org	2003-02-17 04:49:35.000000000 +0100
+++ iconv_module.c	2004-06-17 23:11:18.000000000 +0200
@@ -74,6 +74,40 @@
         return rv;
 }
 
+/*
+ * the follwing stuff is used on Win32 by iconv_getpath()
+ * below.
+ *
+ * based on http://www.codeguru.com/Cpp/W-P/dll/tips/article.php/c3635
+ */
+#ifdef _WIN32
+
+#if _MSC_VER >= 1300
+extern IMAGE_DOS_HEADER __ImageBase;
+#endif
+
+static HMODULE
+__HMODULE()
+{
+#if _MSC_VER < 1300 /* < vc7 */
+
+	static int dummy;
+	MEMORY_BASIC_INFORMATION mbi;
+	VirtualQuery(&dummy,&mbi,sizeof(mbi));
+
+	return (HMODULE)mbi.AllocationBase;
+
+#else
+
+	return (HMODULE)&__ImageBase;
+
+#endif
+}
+
+#endif /*	_WIN32 */
+
+
+
 static apr_status_t
 iconv_getpath(char *buf, const char *name, apr_pool_t *ctx)
 {
@@ -83,16 +117,42 @@
         apr_status_t status;
 	char *ptr;
 
+#ifdef _WIN32
+	char bufferpath[APR_PATH_MAX];
+	apr_finfo_t finfo;
+#endif
+
         status = apr_pool_create(&subpool, ctx);
         if (status)
             return status;
 
 	if (apr_tolower(name[0]) == 'x' && name[1] == '-')
 		name += 2;
+
         ptr = buffer;
         while (0 != (*ptr++ = apr_tolower(*name++)))
             ;
 
+#ifdef _WIN32
+	/*
+	 * on Win32 we first look for the codeset libraries in the folder
+	 * where "this" exe/dll is located (ie. the exe/dll that contains
+	 * this code). If we do not find an iconv folder there we proceed
+	 * as before.
+	 */
+	GetModuleFileNameA(__HMODULE(),bufferpath,sizeof(bufferpath));
+	*(strrchr(bufferpath,'\\')+1) = 0;
+	strcat(bufferpath,ICONV_DEFAULT_PATH);
+
+	if (apr_stat( &finfo, bufferpath, APR_FINFO_TYPE, subpool ) == APR_SUCCESS
+			&& finfo.filetype == APR_DIR )
+	{
+		status = iconv_getpathname(buf, bufferpath, buffer, subpool);
+		apr_pool_destroy(subpool);
+		return status;
+	}
+#endif
+
         if (!apr_env_get(&ptr, "APR_ICONV_PATH", subpool)
             && !apr_filepath_list_split(&pathelts, ptr, subpool))
         {
