[vlc-commits] win32: fix IDN support when building retardedly

Rémi Denis-Courmont git at videolan.org
Fri Nov 18 19:15:21 CET 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Nov 18 19:56:40 2016 +0200| [e5d458a7d85586053ac48ca7431becf5e924cdd5] | committer: Rémi Denis-Courmont

win32: fix IDN support when building retardedly

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e5d458a7d85586053ac48ca7431becf5e924cdd5
---

 src/text/url.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/text/url.c b/src/text/url.c
index 47d2ba3..4430dba 100644
--- a/src/text/url.c
+++ b/src/text/url.c
@@ -832,6 +832,30 @@ char *vlc_uri_fixup(const char *str)
 #elif defined (_WIN32)
 # include <windows.h>
 # include <vlc_charset.h>
+
+# if (_WIN32_WINNT < _WIN32_WINNT_VISTA)
+#  define IDN_ALLOW_UNASSIGNED 0x01
+static int IdnToAscii(DWORD flags, LPCWSTR str, int len, LPWSTR buf, int size)
+{
+    HMODULE h = LoadLibrary(_T("Normaliz.dll"));
+    if (h == NULL)
+    {
+        errno = ENOSYS;
+        return 0;
+    }
+
+    int WINAPI (*IdnToAsciiReal)(DWORD, LPCWSTR, int, LPWSTR, int);
+    int ret = 0;
+
+    IdnToAsciiReal = GetProcAddress(h, "IdnToAscii");
+    if (IdnToAsciiReal != NULL)
+        ret = IdnToAsciiReal(flags, str, len, buf, size);
+    else
+        errno = ENOSYS;
+    FreeLibrary(h);
+    return ret;
+}
+# endif
 #endif
 
 /**
@@ -859,7 +883,7 @@ static char *vlc_idna_to_ascii (const char *idn)
             return NULL;
     }
 
-#elif defined (_WIN32) && (_WIN32_WINNT >= 0x0601)
+#elif defined (_WIN32)
     char *ret = NULL;
 
     if (idn[0] == '\0')



More information about the vlc-commits mailing list