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 );
"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 )
{
*/
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 );
}
/**