[MPlayer-dev-eng] [PATCH] Filename double-conversion

Rich Felker dalias at aerifal.cx
Wed Oct 25 08:10:18 CEST 2006


On Wed, Oct 25, 2006 at 09:20:06AM +0800, Zuxy Meng wrote:
> First convert to utf-8 for input of mp_msg, then convert to
> mp_msg_charset for actually displaying, as suggested by Rich.

> +const char* filename_to_utf8(char* filename)
> +{
> +#ifndef USE_ICONV
> +    return filename;
> +#else
> +    size_t filename_len, max_path;
> +    char* putf8_filename;
> +    if (!strcasecmp(mp_msg_charset, "UTF-8"))
> +	return filename;	
> +    if (inv_msgiconv == (iconv_t)(-1)) {
> +	inv_msgiconv = iconv_open("UTF-8", mp_msg_charset);
> +	if (inv_msgiconv == (iconv_t)(-1))
> +	    return filename;
> +    }
> +    filename_len = strlen(filename);
> +    max_path = MAX_PATH - 1;
> +    putf8_filename = utf8_filename;
> +    iconv(inv_msgiconv, (const char**)&filename, &filename_len,
> +	    &putf8_filename, &max_path);
> +    *putf8_filename = '\0';
> +    return utf8_filename;
> +#endif
> +}
> +

Looks good! But IMO you need to handle the case where mp_msg_charset
is "noconv", if that's still supported. Or maybe we can remove it
now..?

Rich




More information about the MPlayer-dev-eng mailing list