[vlc-commits] commit: NSC: use FromCharset() ( Rémi Denis-Courmont )
git at videolan.org
git at videolan.org
Tue Oct 26 19:13:36 CEST 2010
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Oct 26 19:56:11 2010 +0300| [e8b9642e01560d279c13fb03517c35bf5ab968d8] | committer: Rémi Denis-Courmont
NSC: use FromCharset()
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e8b9642e01560d279c13fb03517c35bf5ab968d8
---
modules/demux/nsc.c | 39 ++++-----------------------------------
1 files changed, 4 insertions(+), 35 deletions(-)
diff --git a/modules/demux/nsc.c b/modules/demux/nsc.c
index 015ab40..da1f9f6 100644
--- a/modules/demux/nsc.c
+++ b/modules/demux/nsc.c
@@ -32,6 +32,7 @@
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_demux.h>
+#include <vlc_charset.h>
#include <ctype.h>
#define MAX_LINE 16024
@@ -147,13 +148,8 @@ static char *nscdec( vlc_object_t *p_demux, char* p_encoded )
unsigned int length;
unsigned char encoding_type;
- vlc_iconv_t conv;
- size_t buf16_size;
unsigned char *buf16;
- const char *p_buf16;
- size_t buf8_size;
char *buf8;
- char *p_buf8;
char *p_input = p_encoded;
@@ -210,8 +206,7 @@ static char *nscdec( vlc_object_t *p_demux, char* p_encoded )
return NULL;
}
- buf16_size = length;
- buf16 = malloc( buf16_size );
+ buf16 = malloc( length );
if( buf16 == NULL )
return NULL;
@@ -225,39 +220,13 @@ static char *nscdec( vlc_object_t *p_demux, char* p_encoded )
}
}
- buf8_size = length;
- buf8 = malloc( buf8_size + 1 );
+ buf8 = FromCharset( "UTF-16LE", buf16, length );
+ free( buf16 );
if( buf8 == NULL )
{
- free( buf16 );
- return NULL;
- }
-
- conv = vlc_iconv_open( "UTF-8", "UTF-16LE" );
- if( conv == (vlc_iconv_t)(-1) )
- {
- msg_Err( p_demux, "iconv_open failed" );
- free( buf16 );
- free( buf8 );
- return NULL;
- }
-
- p_buf8 = buf8;
- p_buf16 = (const char *)buf16;
-
- if( vlc_iconv( conv, &p_buf16, &buf16_size, &p_buf8, &buf8_size ) == (size_t)(-1) )
- {
msg_Err( p_demux, "iconv failed" );
return NULL;
}
- else
- {
- buf8[ length - buf8_size ] = '\0';
- }
-
- vlc_iconv_close( conv );
-
- free( buf16 );
return buf8;
}
More information about the vlc-commits
mailing list