Commit a1730242 authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* Fix FindFallbackEncoding on Mac OS X.

* More distintinctive debug messages on the selection of charset.
parent 6f0d9e49
......@@ -200,7 +200,7 @@ static int OpenDecoder( vlc_object_t *p_this )
if( p_dec->fmt_in.subs.psz_encoding && *p_dec->fmt_in.subs.psz_encoding )
{
msg_Dbg( p_dec, "using character encoding: %s",
msg_Dbg( p_dec, "using demux suggested character encoding: %s",
p_dec->fmt_in.subs.psz_encoding );
if( strcmp( p_dec->fmt_in.subs.psz_encoding, "UTF-8" ) )
p_sys->iconv_handle = vlc_iconv_open( "UTF-8", p_dec->fmt_in.subs.psz_encoding );
......@@ -218,15 +218,15 @@ static int OpenDecoder( vlc_object_t *p_this )
"subsdec-autodetect-utf8" );
p_sys->iconv_handle = vlc_iconv_open( "UTF-8", psz_charset );
msg_Dbg( p_dec, "using default character encoding: %s", psz_charset );
msg_Dbg( p_dec, "using fallback character encoding: %s", psz_charset );
}
else if( !strcmp( val.psz_string, "UTF-8" ) )
{
msg_Dbg( p_dec, "using character encoding: UTF-8" );
msg_Dbg( p_dec, "using enforced character encoding: UTF-8" );
}
else if( val.psz_string )
{
msg_Dbg( p_dec, "using character encoding: %s", val.psz_string );
msg_Dbg( p_dec, "using enforced character encoding: %s", val.psz_string );
p_sys->iconv_handle = vlc_iconv_open( "UTF-8", val.psz_string );
if( p_sys->iconv_handle == (vlc_iconv_t)-1 )
{
......
......@@ -565,11 +565,25 @@ const char *FindFallbackEncoding( const char *locale )
*/
const char *GetFallbackEncoding( void )
{
#if HAVE_SETLOCALE
return FindFallbackEncoding( setlocale( LC_CTYPE, NULL ) );
#else
return FindFallbackEncoding( NULL );
#endif
const char *psz_lang = NULL;
/* Some systems (like Darwin, SunOS 4 or DJGPP) have only the C locale.
* Therefore we don't use setlocale here; it would return "C". */
# if HAVE_SETLOCALE && !__APPLE__
psz_lang = setlocale( LC_ALL, NULL );
# endif
if( psz_lang == NULL || psz_lang[0] == '\0' )
{
psz_lang = getenv( "LC_ALL" );
if( psz_lang == NULL || psz_lang == '\0' )
{
psz_lang = getenv( "LC_CTYPE" );
if( psz_lang == NULL || psz_lang[0] == '\0')
psz_lang = getenv( "LANG" );
}
}
return FindFallbackEncoding( psz_lang );
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment