]> git.sesse.net Git - vlc/commitdiff
subsdec: check UTF-8 autodetection if encoding is not known in ES format
authorKO Myung-Hun <komh@chollian.net>
Sat, 13 Oct 2012 12:12:22 +0000 (21:12 +0900)
committerRémi Denis-Courmont <remi@remlab.net>
Mon, 5 Nov 2012 15:51:27 +0000 (17:51 +0200)
This enables to show UTF-8 subtitles even though subsdec-encoding is set to
a non-UTF-8 value.

Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
modules/codec/subsdec.c

index 118e901335f3145465c98e57948c86604c813be3..5d935ea6abdbe4dad5dd098c259def12368fc10a 100644 (file)
@@ -262,23 +262,24 @@ static int OpenDecoder( vlc_object_t *p_this )
                  encoding);
     }
     else
-    /* Second, try configured encoding */
-    if ((var = var_InheritString (p_dec, "subsdec-encoding")) != NULL)
     {
-        msg_Dbg (p_dec, "trying configured character encoding: %s", var);
-        if (!strcmp (var, "system"))
+        /* Second, try configured encoding */
+        if ((var = var_InheritString (p_dec, "subsdec-encoding")) != NULL)
         {
-            free (var);
-            var = NULL;
-            encoding = "";
-            /* ^ iconv() treats "" as nl_langinfo(CODESET) */
+            msg_Dbg (p_dec, "trying configured character encoding: %s", var);
+            if (!strcmp (var, "system"))
+            {
+                free (var);
+                var = NULL;
+                encoding = "";
+                /* ^ iconv() treats "" as nl_langinfo(CODESET) */
+            }
+            else
+                encoding = var;
         }
         else
-            encoding = var;
-    }
-    else
-    /* Third, try "local" encoding with optional UTF-8 autodetection */
-    {
+        /* Third, try "local" encoding */
+        {
         /* xgettext:
            The Windows ANSI code page most commonly used for this language.
            VLC uses this as a guess of the subtitle files character set
@@ -289,8 +290,11 @@ static int OpenDecoder( vlc_object_t *p_this )
 
            This MUST be a valid iconv character set. If unsure, please refer
            the VideoLAN translators mailing list. */
-        encoding = vlc_pgettext("GetACP", "CP1252");
-        msg_Dbg (p_dec, "trying default character encoding: %s", encoding);
+            encoding = vlc_pgettext("GetACP", "CP1252");
+            msg_Dbg (p_dec, "trying default character encoding: %s", encoding);
+        }
+
+        /* Check UTF-8 autodetection */
         if (var_InheritBool (p_dec, "subsdec-autodetect-utf8"))
         {
             msg_Dbg (p_dec, "using automatic UTF-8 detection");