[vlc-devel] [PATCH 03/41] Workaround for OS/2 iconv(), which 1. supports UCS-2 only not UTF-16 2. does not treat a string as a pathname by default

KO Myung-Hun komh78 at gmail.com
Wed Oct 12 13:47:22 CEST 2011



Rémi Denis-Courmont wrote:
> Le lundi 10 octobre 2011 14:43:42 KO Myung-Hun, vous avez écrit :
>> ---
>>  src/extras/libc.c |   44 ++++++++++++++++++++++++++++++++++++++++++++
>>  1 files changed, 44 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/extras/libc.c b/src/extras/libc.c
>> index 5004480..6a0295e 100644
>> --- a/src/extras/libc.c
>> +++ b/src/extras/libc.c
>> @@ -43,6 +43,15 @@
>>  #   include <iconv.h>
>>  #endif
>>
>> +#ifdef __OS2__
>> +#   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. @@ -332,7 +341,42 @@ 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";
>> +    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", 5 ))
> 
> Should probably be 6 rather than 5.
> 

Oooops... Fixed.

>> +    {
>> +        strncpy( tocode_ucs2 + 5, tocode + 6, 2 );
>> +        tocode = tocode_ucs2;
>> +    }
>> +
>> +    if( !strncmp( fromcode, "UTF-16", 5 ))
> 
> Same problem.
> 

Fixed.

>> +    {
>> +        strncpy( fromcode_ucs2 + 5, fromcode + 6, 2 );
>> +        fromcode = fromcode_ucs2;
>> +    }
>> +
>> +    p_os2_iconv = ( os2_iconv_t * )iconv_open( tocode, fromcode );
>> +
>> +    if( p_os2_iconv != ( iconv_t )(-1))
>> +    {
>> +        /* Assume strings contain pathnames */
>> +        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 );
>> +    }
> 
> I don't understand this if-block at all. It seems totally out of place. If you 
> need to convert paths differently, then you should modify FromLocale() and the 
> likes instead.
> 

This is a hack for iconv() implementation of kLIBC.

This changes the behavior of iconv() to treat a string as a path.

Some asian countries uses '\' as their currency symbol.

This prevents '\' from converting to the currency symbol.

>> +
>> +    return ( vlc_iconv_t )p_os2_iconv;
>> +# else
>>      return iconv_open( tocode, fromcode );
>> +# endif
>>  #else
>>      return (vlc_iconv_t)(-1);
>>  #endif
> 
> 

-- 
KO Myung-Hun

Using Mozilla SeaMonkey 2.0.14
Under OS/2 Warp 4 for Korean with FixPak #15
On AMD ThunderBird 1GHz with 512 MB RAM

Korean OS/2 User Community : http://www.ecomstation.co.kr

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0003-Workaround-for-OS-2-iconv-which-1.-supports-UCS-2-on.patch
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20111012/b066f2a2/attachment.ksh>


More information about the vlc-devel mailing list