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

UTF32 to UTF8 conversion

because the buggy GUI toolkit that sucks big time^W^W^W^W^W^W^WwxWidgets
needs it
parent 918b5afd
...@@ -30,6 +30,7 @@ VLC_EXPORT( void, LocaleFree, ( const char * ) ); ...@@ -30,6 +30,7 @@ VLC_EXPORT( void, LocaleFree, ( const char * ) );
VLC_EXPORT( char *, FromLocale, ( const char * ) ); VLC_EXPORT( char *, FromLocale, ( const char * ) );
VLC_EXPORT( char *, ToLocale, ( const char * ) ); VLC_EXPORT( char *, ToLocale, ( const char * ) );
VLC_EXPORT( char *, EnsureUTF8, ( char * ) ); VLC_EXPORT( char *, EnsureUTF8, ( char * ) );
VLC_EXPORT( char *, FromUTF32, ( wchar_t * ) );
VLC_EXPORT( char *, __vlc_fix_readdir_charset, ( vlc_object_t *, const char * ) ); VLC_EXPORT( char *, __vlc_fix_readdir_charset, ( vlc_object_t *, const char * ) );
#define vlc_fix_readdir_charset(a,b) __vlc_fix_readdir_charset(VLC_OBJECT(a),b) #define vlc_fix_readdir_charset(a,b) __vlc_fix_readdir_charset(VLC_OBJECT(a),b)
......
...@@ -385,6 +385,7 @@ void sout_MuxDeleteStream (sout_mux_t *, sout_input_t *); ...@@ -385,6 +385,7 @@ void sout_MuxDeleteStream (sout_mux_t *, sout_input_t *);
char * httpd_MsgGet (httpd_message_t *, char *psz_name); char * httpd_MsgGet (httpd_message_t *, char *psz_name);
const iso639_lang_t * GetLang_1 (const char *); const iso639_lang_t * GetLang_1 (const char *);
void aout_FormatsPrint (aout_instance_t * p_aout, const char * psz_text, const audio_sample_format_t * p_format1, const audio_sample_format_t * p_format2); void aout_FormatsPrint (aout_instance_t * p_aout, const char * psz_text, const audio_sample_format_t * p_format1, const audio_sample_format_t * p_format2);
char * FromUTF32 (wchar_t *);
void __vout_OSDMessage (vlc_object_t *, int, char *, ...); void __vout_OSDMessage (vlc_object_t *, int, char *, ...);
void intf_StopThread (intf_thread_t *); void intf_StopThread (intf_thread_t *);
stream_t * __stream_MemoryNew (vlc_object_t *p_obj, uint8_t *p_buffer, int64_t i_size, vlc_bool_t i_preserve_memory); stream_t * __stream_MemoryNew (vlc_object_t *p_obj, uint8_t *p_buffer, int64_t i_size, vlc_bool_t i_preserve_memory);
...@@ -815,7 +816,6 @@ struct module_symbols_t ...@@ -815,7 +816,6 @@ struct module_symbols_t
osd_state_t * (*__osd_StateChange_inner) (osd_state_t *, const int); osd_state_t * (*__osd_StateChange_inner) (osd_state_t *, const int);
void (*osd_ConfigUnload_inner) (vlc_object_t *, osd_menu_t **); void (*osd_ConfigUnload_inner) (vlc_object_t *, osd_menu_t **);
void (*__osd_MenuShow_inner) (vlc_object_t *); void (*__osd_MenuShow_inner) (vlc_object_t *);
void *__osd_VolumeDown_deprecated;
void (*__osd_MenuNext_inner) (vlc_object_t *); void (*__osd_MenuNext_inner) (vlc_object_t *);
void (*__osd_MenuDelete_inner) (vlc_object_t *, osd_menu_t *); void (*__osd_MenuDelete_inner) (vlc_object_t *, osd_menu_t *);
void (*__osd_MenuHide_inner) (vlc_object_t *); void (*__osd_MenuHide_inner) (vlc_object_t *);
...@@ -846,6 +846,7 @@ struct module_symbols_t ...@@ -846,6 +846,7 @@ struct module_symbols_t
void (*osd_Message_inner) (spu_t *, int, char *, ...); void (*osd_Message_inner) (spu_t *, int, char *, ...);
int (*osd_ShowTextAbsolute_inner) (spu_t *, int, char *, text_style_t *, int, int, int, mtime_t, mtime_t); int (*osd_ShowTextAbsolute_inner) (spu_t *, int, char *, text_style_t *, int, int, int, mtime_t, mtime_t);
char * (*config_GetUserDir_inner) (void); char * (*config_GetUserDir_inner) (void);
char * (*FromUTF32_inner) (wchar_t *);
}; };
# if defined (__PLUGIN__) # if defined (__PLUGIN__)
# define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner # define aout_FiltersCreatePipeline (p_symbols)->aout_FiltersCreatePipeline_inner
...@@ -1254,6 +1255,7 @@ struct module_symbols_t ...@@ -1254,6 +1255,7 @@ struct module_symbols_t
# define osd_Message (p_symbols)->osd_Message_inner # define osd_Message (p_symbols)->osd_Message_inner
# define osd_ShowTextAbsolute (p_symbols)->osd_ShowTextAbsolute_inner # define osd_ShowTextAbsolute (p_symbols)->osd_ShowTextAbsolute_inner
# define config_GetUserDir (p_symbols)->config_GetUserDir_inner # define config_GetUserDir (p_symbols)->config_GetUserDir_inner
# define FromUTF32 (p_symbols)->FromUTF32_inner
# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) # elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__)
/****************************************************************** /******************************************************************
* STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access. * STORE_SYMBOLS: store VLC APIs into p_symbols for plugin access.
...@@ -1665,8 +1667,8 @@ struct module_symbols_t ...@@ -1665,8 +1667,8 @@ struct module_symbols_t
((p_symbols)->osd_Message_inner) = osd_Message; \ ((p_symbols)->osd_Message_inner) = osd_Message; \
((p_symbols)->osd_ShowTextAbsolute_inner) = osd_ShowTextAbsolute; \ ((p_symbols)->osd_ShowTextAbsolute_inner) = osd_ShowTextAbsolute; \
((p_symbols)->config_GetUserDir_inner) = config_GetUserDir; \ ((p_symbols)->config_GetUserDir_inner) = config_GetUserDir; \
((p_symbols)->FromUTF32_inner) = FromUTF32; \
(p_symbols)->net_ConvertIPv4_deprecated = NULL; \ (p_symbols)->net_ConvertIPv4_deprecated = NULL; \
(p_symbols)->__osd_VolumeDown_deprecated = NULL; \
# endif /* __PLUGIN__ */ # endif /* __PLUGIN__ */
# endif /* HAVE_SHARED_LIBVLC */ # endif /* HAVE_SHARED_LIBVLC */
......
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
* charset.c: Determine a canonical name for the current locale's character * charset.c: Determine a canonical name for the current locale's character
* encoding. * encoding.
***************************************************************************** *****************************************************************************
* Copyright (C) 2003-2004 the VideoLAN team * Copyright (C) 2003-2005 the VideoLAN team
* $Id$ * $Id$
* *
* Author: Derk-Jan Hartman <thedj at users.sf.net> * Authors: Derk-Jan Hartman <thedj at users.sf.net>
* Rémi Denis-Courmont <rem at videolan.org>
* *
* vlc_current_charset() an adaption of mp_locale_charset(): * vlc_current_charset() an adaption of mp_locale_charset():
* *
...@@ -374,3 +375,69 @@ char *__vlc_fix_readdir_charset( vlc_object_t *p_this, const char *psz_string ) ...@@ -374,3 +375,69 @@ char *__vlc_fix_readdir_charset( vlc_object_t *p_this, const char *psz_string )
return strdup( psz_string ); return strdup( psz_string );
} }
/**********************************************************************
* UTF32toUTF8: converts UTF-32 to UTF-8
*********************************************************************/
char *UTF32toUTF8( wchar_t *src, size_t len, size_t *newlen )
{
char *res, *out;
/* allocate memory */
out = res = (char *)malloc( 6 * len );
if( res == NULL )
return NULL;
while( len >= sizeof( wchar_t ) )
{
uint32_t uv = *src++;
len--;
if( uv < 0x80 )
{
*out++ = uv;
continue;
}
else
if( uv < 0x800 )
{
*out++ = (( uv >> 6) | 0xc0);
*out++ = (( uv & 0x3f) | 0x80);
continue;
}
else
if( uv < 0x10000 )
{
*out++ = (( uv >> 12) | 0xe0);
*out++ = (((uv >> 6) & 0x3f) | 0x80);
*out++ = (( uv & 0x3f) | 0x80);
continue;
}
else
{
*out++ = (( uv >> 18) | 0xf0);
*out++ = (((uv >> 12) & 0x3f) | 0x80);
*out++ = (((uv >> 6) & 0x3f) | 0x80);
*out++ = (( uv & 0x3f) | 0x80);
continue;
}
}
len = out - res;
res = realloc( res, len );
if( newlen != NULL )
*newlen = len;
return res;
}
char *FromUTF32( wchar_t *src )
{
size_t len;
wchar_t *in;
/* determine the size of the string */
for( len = 1, in = src; GetWBE( in ); len++ )
in++;
return UTF32toUTF8( src, len, NULL );
}
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