diff --git a/xmlIO.c b/xmlIO.c
index 855bf41..8f81529 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -613,6 +613,32 @@ xmlWrapOpenUtf8(const char *path,int mode)
     return fd;
 }
 
+static gzFile
+xmlWrapGzOpenUtf8(const char *path, const char *mode)
+{
+    gzFile fd;
+    wchar_t *wPath;
+	
+    fd = gzopen (path, mode);
+    if (fd)
+        return fd;
+
+    wPath = __xmlIOWin32UTF8ToWChar(path);
+    if(wPath)
+    {
+	int d, m = (strstr(mode, "r") ? O_RDONLY : O_RDWR);
+#ifdef _O_BINARY
+        m |= (strstr(mode, "b") ? _O_BINARY : 0);
+#endif
+	d = _wopen(wPath, m);
+	if (d >= 0)
+	    fd = gzdopen(d, mode); 
+        xmlFree(wPath);
+    }
+	
+    return fd;
+}
+
 /**
  *  xmlWrapStatUtf8:
  * @path:  the path in utf-8 encoding
@@ -679,6 +705,8 @@ typedef int (* xmlWrapStatFunc) (const char *f, struct stat *s);
 static xmlWrapStatFunc xmlWrapStat = xmlWrapStatNative;
 typedef FILE* (* xmlWrapOpenFunc)(const char *f,int mode);
 static xmlWrapOpenFunc xmlWrapOpen = xmlWrapOpenNative;
+typedef gzFile (* xmlWrapGzOpenFunc) (const char *f, const char *mode);
+static xmlWrapGzOpenFunc xmlWrapGzOpen = gzopen;
 
 /**
  * xmlInitPlatformSpecificIo:
@@ -699,9 +727,11 @@ xmlInitPlatformSpecificIo(void)
     if(GetVersionEx(&osvi) && (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)) {
       xmlWrapStat = xmlWrapStatUtf8;
       xmlWrapOpen = xmlWrapOpenUtf8;
+      xmlWrapGzOpen = xmlWrapGzOpenUtf8;
     } else {
       xmlWrapStat = xmlWrapStatNative;
       xmlWrapOpen = xmlWrapOpenNative;
+      xmlWrapGzOpen = gzopen;
     }
 
     xmlPlatformIoInitialized = 1;
@@ -1132,7 +1162,11 @@ xmlGzfileOpen_real (const char *filename) {
     if (!xmlCheckFilename(path))
         return(NULL);
 
+#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
+    fd = xmlWrapGzOpen(path, "rb");
+#else
     fd = gzopen(path, "rb");
+#endif
     return((void *) fd);
 }
 
@@ -1200,7 +1234,11 @@ xmlGzfileOpenW (const char *filename, int compression) {
     if (path == NULL)
 	return(NULL);
 
+#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
+    fd = xmlWrapGzOpen(path, mode);
+#else
     fd = gzopen(path, mode);
+#endif
     return((void *) fd);
 }
 #endif /* LIBXML_OUTPUT_ENABLED */
