[vlc-commits] Mimic a behavior of GNU libiconv on OS/2
KO Myung-Hun
git at videolan.org
Sat Mar 24 16:58:16 CET 2012
vlc/vlc-2.0 | branch: master | KO Myung-Hun <komh78 at gmail.com> | Fri Mar 2 23:58:02 2012 +0900| [875f8c7c29538dfcbdccdde72badd2d5d9da1d45] | committer: Rémi Denis-Courmont
Mimic a behavior of GNU libiconv on OS/2
DBCS countries assign their currency symbol to '\', ASCII 92. This causes
an unexpected behavior when converting a directory separator on OS/2.
In case of GNU libiconv, it does not treat '\', ASCII 92, as a currency
symbol at all. So let's mimic GNU libiconv.
Signed-off-by: Rafaël Carré <funman at videolan.org>
(cherry picked from commit 8acdc1f532606e84d70c26066dc750a5a1867ac2)
Signed-off-by: KO Myung-Hun <komh at chollian.net>
Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=875f8c7c29538dfcbdccdde72badd2d5d9da1d45
---
src/extras/libc.c | 29 ++++++++++++++++++++++++++++-
1 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/src/extras/libc.c b/src/extras/libc.c
index 08b19fc..3389c57 100644
--- a/src/extras/libc.c
+++ b/src/extras/libc.c
@@ -37,6 +37,15 @@
# include <iconv.h>
#endif
+#if defined(__OS2__) && defined(__INNOTEK_LIBC__)
+# include <uconv.h>
+
+typedef struct os2_iconv_t
+{
+ UconvObject from;
+} os2_iconv_t;
+#endif
+
/*****************************************************************************
* Local conversion routine from ISO_6937 to UTF-8 charset. Support for this
* is still missing in libiconv, hence multiple operating systems lack it.
@@ -329,6 +338,7 @@ vlc_iconv_t vlc_iconv_open( const char *tocode, const char *fromcode )
# if defined(__OS2__) && defined(__INNOTEK_LIBC__)
char tocode_ucs2[] = "UCS-2LE";
char fromcode_ucs2[] = "UCS-2LE";
+ os2_iconv_t *p_os2_iconv;
/* Workaround for UTF-16 because OS/2 supports UCS-2 only not UTF-16 */
if( !strncmp( tocode, "UTF-16", 6 ))
@@ -342,8 +352,25 @@ vlc_iconv_t vlc_iconv_open( const char *tocode, const char *fromcode )
strncpy( fromcode_ucs2 + 5, fromcode + 6, 2 );
fromcode = fromcode_ucs2;
}
-# endif
+
+ p_os2_iconv = ( os2_iconv_t * )iconv_open( tocode, fromcode );
+
+ if( p_os2_iconv != ( iconv_t )(-1))
+ {
+ /* Mimic a behavior of GNU libiconv */
+ uconv_attribute_t attr;
+
+ UniQueryUconvObject( p_os2_iconv->from, &attr,
+ sizeof( uconv_attribute_t ),
+ NULL, NULL, NULL );
+ attr.converttype |= CVTTYPE_PATH;
+ UniSetUconvObject( p_os2_iconv->from, &attr );
+ }
+
+ return ( vlc_iconv_t )p_os2_iconv;
+# else
return iconv_open( tocode, fromcode );
+# endif
#else
return (vlc_iconv_t)(-1);
#endif
More information about the vlc-commits
mailing list