]> git.sesse.net Git - vlc/commitdiff
Treat UTF-16 as UCS-2 on OS/2
authorKO Myung-Hun <komh78@gmail.com>
Tue, 10 Jan 2012 12:07:02 +0000 (21:07 +0900)
committerRafaël Carré <funman@videolan.org>
Fri, 17 Feb 2012 08:46:58 +0000 (03:46 -0500)
OS/2 supports UCS-2 only instead of UTF-16.

Signed-off-by: Rafaël Carré <funman@videolan.org>
src/extras/libc.c

index 6df1a52344eb65b2134937f33b2521cae3997f47..08b19fca88c71f4983d4f092304a24f3d173f689 100644 (file)
@@ -326,6 +326,23 @@ vlc_iconv_t vlc_iconv_open( const char *tocode, const char *fromcode )
         return (vlc_iconv_t)(-2);
 #endif
 #if defined(HAVE_ICONV)
+# if defined(__OS2__) && defined(__INNOTEK_LIBC__)
+    char tocode_ucs2[] = "UCS-2LE";
+    char fromcode_ucs2[] = "UCS-2LE";
+
+    /* Workaround for UTF-16 because OS/2 supports UCS-2 only not UTF-16 */
+    if( !strncmp( tocode, "UTF-16", 6 ))
+    {
+        strncpy( tocode_ucs2 + 5, tocode + 6, 2 );
+        tocode = tocode_ucs2;
+    }
+
+    if( !strncmp( fromcode, "UTF-16", 6 ))
+    {
+        strncpy( fromcode_ucs2 + 5, fromcode + 6, 2 );
+        fromcode = fromcode_ucs2;
+    }
+# endif
     return iconv_open( tocode, fromcode );
 #else
     return (vlc_iconv_t)(-1);