00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef VLC_CHARSET_H
00026 #define VLC_CHARSET_H 1
00027
00028
00029
00030
00031
00032
00033 #include <stdarg.h>
00034 #include <sys/types.h>
00035 #include <dirent.h>
00036
00037 VLC_EXPORT( void, LocaleFree, ( const char * ) );
00038 VLC_EXPORT( char *, FromLocale, ( const char * ) LIBVLC_USED );
00039 VLC_EXPORT( char *, FromLocaleDup, ( const char * ) LIBVLC_USED );
00040 VLC_EXPORT( char *, ToLocale, ( const char * ) LIBVLC_USED );
00041 VLC_EXPORT( char *, ToLocaleDup, ( const char * ) LIBVLC_USED );
00042
00043
00044 VLC_EXPORT( int, utf8_open, ( const char *filename, int flags, ... ) LIBVLC_USED );
00045 VLC_EXPORT( FILE *, utf8_fopen, ( const char *filename, const char *mode ) LIBVLC_USED );
00046 VLC_EXPORT( DIR *, utf8_opendir, ( const char *dirname ) LIBVLC_USED );
00047 VLC_EXPORT( char *, utf8_readdir, ( DIR *dir ) LIBVLC_USED );
00048 VLC_EXPORT( int, utf8_loaddir, ( DIR *dir, char ***namelist, int (*select)( const char * ), int (*compar)( const char **, const char ** ) ) );
00049 VLC_EXPORT( int, utf8_scandir, ( const char *dirname, char ***namelist, int (*select)( const char * ), int (*compar)( const char **, const char ** ) ) );
00050 VLC_EXPORT( int, utf8_mkdir, ( const char *filename, mode_t mode ) );
00051 VLC_EXPORT( int, utf8_unlink, ( const char *filename ) );
00052 int utf8_rename( const char *, const char * );
00053
00054 #if defined( WIN32 ) && !defined( UNDER_CE )
00055 # define stat _stati64
00056 #endif
00057
00058 VLC_EXPORT( int, utf8_stat, ( const char *filename, struct stat *buf ) );
00059 VLC_EXPORT( int, utf8_lstat, ( const char *filename, struct stat *buf ) );
00060
00061 VLC_EXPORT( int, utf8_vfprintf, ( FILE *stream, const char *fmt, va_list ap ) );
00062 VLC_EXPORT( int, utf8_fprintf, ( FILE *, const char *, ... ) LIBVLC_FORMAT( 2, 3 ) );
00063
00064 VLC_EXPORT( int, utf8_mkstemp, ( char * ) );
00065
00066 VLC_EXPORT( char *, EnsureUTF8, ( char * ) );
00067 VLC_EXPORT( const char *, IsUTF8, ( const char * ) LIBVLC_USED );
00068
00069 #ifdef WIN32
00070 LIBVLC_USED
00071 static inline char *FromWide (const wchar_t *wide)
00072 {
00073 size_t len = WideCharToMultiByte (CP_UTF8, 0, wide, -1, NULL, 0, NULL, NULL);
00074 if (len == 0)
00075 return NULL;
00076
00077 char *out = (char *)malloc (len);
00078
00079 if (out)
00080 WideCharToMultiByte (CP_UTF8, 0, wide, -1, out, len, NULL, NULL);
00081 return out;
00082 }
00083 #endif
00084
00085
00086
00087
00088 static inline char *FromLatin1 (const char *latin)
00089 {
00090 char *str = (char *)malloc (2 * strlen (latin) + 1), *utf8 = str;
00091 unsigned char c;
00092
00093 if (str == NULL)
00094 return NULL;
00095
00096 while ((c = *(latin++)) != '\0')
00097 {
00098 if (c >= 0x80)
00099 {
00100 *(utf8++) = 0xC0 | (c >> 6);
00101 *(utf8++) = 0x80 | (c & 0x3F);
00102 }
00103 else
00104 *(utf8++) = c;
00105 }
00106 *(utf8++) = '\0';
00107
00108 utf8 = (char *)realloc (str, utf8 - str);
00109 return utf8 ? utf8 : str;
00110 }
00111
00112 VLC_EXPORT( const char *, GetFallbackEncoding, ( void ) LIBVLC_USED );
00113
00114 VLC_EXPORT( double, us_strtod, ( const char *, char ** ) LIBVLC_USED );
00115 VLC_EXPORT( float, us_strtof, ( const char *, char ** ) LIBVLC_USED );
00116 VLC_EXPORT( double, us_atof, ( const char * ) LIBVLC_USED );
00117 VLC_EXPORT( int, us_asprintf, ( char **, const char *, ... ) LIBVLC_USED );
00118
00119 #endif