]> git.sesse.net Git - vlc/blobdiff - modules/codec/subtitles/subsdec.c
subsdec: add a special "local system" character set
[vlc] / modules / codec / subtitles / subsdec.c
index b2243163de401e490331e68536cbda9bf8d183c0..b128859b0317b5729e4bf1c3798db3e6e70dfab1 100644 (file)
@@ -51,6 +51,7 @@ static char           *CreateHtmlSubtitle( int *pi_align, char * );
  *****************************************************************************/
 static const char *const ppsz_encodings[] = {
     "",
+    "system",
     "UTF-8",
     "UTF-16",
     "UTF-16BE",
@@ -94,7 +95,12 @@ static const char *const ppsz_encodings[] = {
 };
 
 static const char *const ppsz_encoding_names[] = {
-    N_("Auto"),
+    /* xgettext:
+      The character encoding name in parenthesis corresponds to that used for
+      the GetACP translation. "Windows-1252" applies to Western European
+      languages using the Latin alphabet. */
+    N_("Default (Windows-1252)"),
+    N_("System codeset"),
     N_("Universal (UTF-8)"),
     N_("Universal (UTF-16)"),
     N_("Universal (big endian UTF-16)"),
@@ -275,9 +281,15 @@ static int OpenDecoder( vlc_object_t *p_this )
     /* Second, try configured encoding */
     if (psz_charset == NULL)
     {
-        psz_charset = var_CreateGetNonEmptyString (p_dec, "subsdec-encoding");
+        psz_charset = var_InheritString (p_dec, "subsdec-encoding");
         msg_Dbg (p_dec, "trying configured character encoding: %s",
                  psz_charset ? psz_charset : "not specified");
+        if (!strcmp (psz_charset, "system"))
+        {
+            free (psz_charset);
+            psz_charset = strdup ("");
+            /* ^ iconv() treats "" as nl_langinfo(CODESET) */
+        }
     }
 
     /* Third, try "local" encoding with optional UTF-8 autodetection */
@@ -299,7 +311,7 @@ static int OpenDecoder( vlc_object_t *p_this )
         msg_Dbg (p_dec, "trying default character encoding: %s",
                  psz_charset ? psz_charset : "not specified");
 
-        if (var_CreateGetBool (p_dec, "subsdec-autodetect-utf8"))
+        if (var_InheritBool (p_dec, "subsdec-autodetect-utf8"))
         {
             msg_Dbg (p_dec, "using automatic UTF-8 detection");
             p_sys->b_autodetect_utf8 = true;
@@ -323,10 +335,10 @@ static int OpenDecoder( vlc_object_t *p_this )
     }
     free (psz_charset);
 
-    p_sys->i_align = var_CreateGetInteger( p_dec, "subsdec-align" );
+    p_sys->i_align = var_InheritInteger( p_dec, "subsdec-align" );
 
     if( p_dec->fmt_in.i_codec == VLC_CODEC_SSA
-     && var_CreateGetBool( p_dec, "subsdec-formatted" ) )
+     && var_InheritBool( p_dec, "subsdec-formatted" ) )
     {
         if( p_dec->fmt_in.i_extra > 0 )
             ParseSSAHeader( p_dec );
@@ -495,7 +507,7 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
     }
 
     /* Create the subpicture unit */
-    p_spu = decoder_NewSubpicture( p_dec );
+    p_spu = decoder_NewSubpicture( p_dec, NULL );
     if( !p_spu )
     {
         msg_Warn( p_dec, "can't get spu buffer" );
@@ -528,7 +540,7 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
         /* Remove formatting from string */
 
         p_spu->p_region->psz_text = StripTags( psz_subtitle );
-        if( var_CreateGetBool( p_dec, "subsdec-formatted" ) )
+        if( var_InheritBool( p_dec, "subsdec-formatted" ) )
         {
             p_spu->p_region->psz_html = CreateHtmlSubtitle( &p_spu->p_region->i_align, psz_subtitle );
         }