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

MMS: use ToCharset()

parent f8471e1d
...@@ -108,34 +108,26 @@ void var_buffer_addmemory( var_buffer_t *p_buf, void *p_mem, int i_mem ) ...@@ -108,34 +108,26 @@ void var_buffer_addmemory( var_buffer_t *p_buf, void *p_mem, int i_mem )
void var_buffer_addUTF16( var_buffer_t *p_buf, const char *p_str ) void var_buffer_addUTF16( var_buffer_t *p_buf, const char *p_str )
{ {
unsigned int i; uint16_t *p_out;
if( !p_str ) size_t i_out;
{
var_buffer_add16( p_buf, 0 ); if( p_str != NULL )
} #ifdef WORDS_BIGENDIAN
p_out = ToCharset( "UTF-16BE", p_str, &i_out );
#else
p_out = ToCharset( "UTF-16LE", p_str, &i_out );
#endif
else else
{ p_out = NULL;
vlc_iconv_t iconv_handle; if( p_out == NULL )
size_t i_in = strlen( p_str ); i_out = 0;
size_t i_out = i_in * 4;
char *psz_out, *psz_tmp; i_out /= 2;
for( size_t i = 0; i < i_out; i ++ )
psz_out = psz_tmp = xmalloc( i_out + 1 ); var_buffer_add16( p_buf, p_out[i] );
iconv_handle = vlc_iconv_open( "UTF-16LE", "UTF-8" ); free( p_out );
vlc_iconv( iconv_handle, &p_str, &i_in, &psz_tmp, &i_out );
vlc_iconv_close( iconv_handle ); var_buffer_add16( p_buf, 0 );
psz_tmp[0] = '\0';
psz_tmp[1] = '\0';
for( i = 0; ; i += 2 )
{
uint16_t v = GetWLE( &psz_out[i] );
var_buffer_add16( p_buf, v );
if( !v )
break;
}
free( psz_out );
}
} }
void var_buffer_free( var_buffer_t *p_buf ) void var_buffer_free( var_buffer_t *p_buf )
......
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