]> git.sesse.net Git - vlc/commitdiff
* Fix FindFallbackEncoding on Mac OS X.
authorDerk-Jan Hartman <hartman@videolan.org>
Mon, 3 Apr 2006 01:39:59 +0000 (01:39 +0000)
committerDerk-Jan Hartman <hartman@videolan.org>
Mon, 3 Apr 2006 01:39:59 +0000 (01:39 +0000)
* More distintinctive debug messages on the selection of charset.

modules/codec/subsdec.c
src/misc/charset.c

index 01fe977885ce5fd19c091f19429f6e95627f0df3..2d7a8b52f5723ea33a3b41fec14eea6832f0e080 100644 (file)
@@ -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 )
             {
index d9079a9266bccde6613df07ca493e019a9a0cb3c..3a965b3642dd7c9c4a5d4647e5cae43982c85922 100644 (file)
@@ -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 );
 }
 
 /**