>From 7aa8ee06a1166fb419843b553de637b34a67d842 Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <komh@chollian.net>
Date: Sat, 13 Oct 2012 21:12:22 +0900
Subject: [PATCH 2/3] subsdec: check UTF-8 autodetection if encoding is not known in ES format

This enables to show UTF-8 subtitles even though subsdec-encoding is set to
a non-UTF-8 value.
---
 modules/codec/subsdec.c |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/modules/codec/subsdec.c b/modules/codec/subsdec.c
index 118e901..5d935ea 100644
--- a/modules/codec/subsdec.c
+++ b/modules/codec/subsdec.c
@@ -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");
-- 
1.7.3.2

