Commit e8b9642e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

NSC: use FromCharset()

parent b507be16
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <vlc_common.h> #include <vlc_common.h>
#include <vlc_plugin.h> #include <vlc_plugin.h>
#include <vlc_demux.h> #include <vlc_demux.h>
#include <vlc_charset.h>
#include <ctype.h> #include <ctype.h>
#define MAX_LINE 16024 #define MAX_LINE 16024
...@@ -147,13 +148,8 @@ static char *nscdec( vlc_object_t *p_demux, char* p_encoded ) ...@@ -147,13 +148,8 @@ static char *nscdec( vlc_object_t *p_demux, char* p_encoded )
unsigned int length; unsigned int length;
unsigned char encoding_type; unsigned char encoding_type;
vlc_iconv_t conv;
size_t buf16_size;
unsigned char *buf16; unsigned char *buf16;
const char *p_buf16;
size_t buf8_size;
char *buf8; char *buf8;
char *p_buf8;
char *p_input = p_encoded; char *p_input = p_encoded;
...@@ -210,8 +206,7 @@ static char *nscdec( vlc_object_t *p_demux, char* p_encoded ) ...@@ -210,8 +206,7 @@ static char *nscdec( vlc_object_t *p_demux, char* p_encoded )
return NULL; return NULL;
} }
buf16_size = length; buf16 = malloc( length );
buf16 = malloc( buf16_size );
if( buf16 == NULL ) if( buf16 == NULL )
return NULL; return NULL;
...@@ -225,39 +220,13 @@ static char *nscdec( vlc_object_t *p_demux, char* p_encoded ) ...@@ -225,39 +220,13 @@ static char *nscdec( vlc_object_t *p_demux, char* p_encoded )
} }
} }
buf8_size = length; buf8 = FromCharset( "UTF-16LE", buf16, length );
buf8 = malloc( buf8_size + 1 );
if( buf8 == NULL )
{
free( buf16 ); free( buf16 );
return NULL; if( buf8 == 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" ); msg_Err( p_demux, "iconv failed" );
return NULL; return NULL;
} }
else
{
buf8[ length - buf8_size ] = '\0';
}
vlc_iconv_close( conv );
free( buf16 );
return buf8; return buf8;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment