예제 #1
0
파일: charset.c 프로젝트: forthyen/SDesk
/* Returns charset from "language_COUNTRY.charset@modifier" string */
static char *vlc_encoding_from_locale( char *psz_locale )
{
    char *psz_dot = strchr( psz_locale, '.' );

    if( psz_dot != NULL )
    {
        const char *psz_modifier;
        static char buf[2 + 10 + 1];

        psz_dot++;

        /* Look for the possible @... trailer and remove it, if any.  */
        psz_modifier = strchr( psz_dot, '@' );

        if( psz_modifier == NULL )
            return psz_dot;
        if( 0 < ( psz_modifier - psz_dot ) < sizeof( buf ))
        {
            memcpy( buf, psz_dot, psz_modifier - psz_dot );
            buf[ psz_modifier - psz_dot ] = '\0';
            return buf;
        }
    }
    /* try language mapping */
    return (char *)vlc_encoding_from_language( psz_locale );
}
예제 #2
0
static void vlc_encoding_from_locale( char *psz_locale, char *psz_charset )
{
    char *psz_dot = strchr( psz_locale, '.' );

    if( psz_dot != NULL )
    {
        const char *psz_modifier;

        psz_dot++;

        /* Look for the possible @... trailer and remove it, if any.  */
        psz_modifier = strchr( psz_dot, '@' );

        if( psz_modifier == NULL )
        {
            strcpy( psz_charset, psz_dot );
            return;
        }
        if( 0 < ( psz_modifier - psz_dot )
             && ( psz_modifier - psz_dot ) < 2 + 10 + 1 )
        {
            memcpy( psz_charset, psz_dot, psz_modifier - psz_dot );
            psz_charset[ psz_modifier - psz_dot ] = '\0';
            return;
        }
    }
    /* try language mapping */
    strcpy( psz_charset, vlc_encoding_from_language( psz_locale ) );
}