[vlc-devel] [patch] add subtitles autodetect
Savin Alex
alexo.veto at gmail.com
Mon Jun 28 14:27:23 CEST 2010
add subtitles autodetect,
it also required enca library,
should work, but I don't know how add enca library to vlc build config, so can't test
diff --git a/src/input/stream.c b/src/input/stream.c
index f0a90dc..9da32ad 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -27,6 +27,9 @@
#include <dirent.h>
#include <assert.h>
+#include <enca.h>
+#include <string.h>
+#include <stdlib.h>
#include <vlc_common.h>
#include <vlc_strings.h>
@@ -1501,6 +1504,23 @@ char *stream_ReadLine( stream_t *s )
int i_bom_size = 0;
const char *psz_encoding = NULL;
+ if (getenv("LANG")){
+ char lang[3];
+ strncpy(lang, getenv("LANG"), 2));
+ lang[2]=0;
+ EncaAnalyser analyser;
+ EncaEncoding encoding;
+ const int bufferlen=16384;
+ const uint8_t **ppchar;
+ int data_len = stream_Peek( s, ppchar, bufferlen );
+ analyser = enca_analyser_alloc((const char *)lang);
+ if (analyser){
+ encoding = enca_analyse_const(analyser, (unsigned char *)ppchar, &data_len);
+ psz_encoding = enca_charset_name(encoding.charset, ENCA_NAME_STYLE_ICONV);
+ }
+ //enca_analyser_free (analyser);
+ }
+
if( !memcmp( p_data, "\xEF\xBB\xBF", 3 ) )
{
psz_encoding = "UTF-8";
--
Best regards, Александр
mailto:alexo.veto at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vlc_sub_enc_autodetect.patch
Type: text/x-patch
Size: 1334 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20100628/50fb5251/attachment.bin>
More information about the vlc-devel
mailing list