]> git.sesse.net Git - vlc/blob - include/charset.h
Fixes order of operands in a substraction.
[vlc] / include / charset.h
1 /*****************************************************************************
2  * charset.h: Unicode UTF-8 wrappers function
3  *****************************************************************************
4  * Copyright (C) 2003-2005 the VideoLAN team
5  * Copyright © 2005-2006 Rémi Denis-Courmont
6  * $Id$
7  *
8  * Author: Rémi Denis-Courmont <rem # videolan,org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef __VLC_CHARSET_H
26 #define __VLC_CHARSET_H 1
27
28 #include <stdarg.h>
29 #include <sys/types.h>
30 #include <dirent.h>
31
32 VLC_EXPORT( void, LocaleFree, ( const char * ) );
33 VLC_EXPORT( char *, FromLocale, ( const char * ) );
34 VLC_EXPORT( char *, FromLocaleDup, ( const char * ) );
35 VLC_EXPORT( char *, ToLocale, ( const char * ) );
36
37 VLC_EXPORT( int, utf8_open, ( const char *filename, int flags, mode_t mode ) );
38 VLC_EXPORT( FILE *, utf8_fopen, ( const char *filename, const char *mode ) );
39 VLC_EXPORT( DIR *, utf8_opendir, ( const char *dirname ) );
40 VLC_EXPORT( char *, utf8_readdir, ( DIR *dir ) );
41 VLC_EXPORT( int, utf8_scandir, ( const char *dirname, char ***namelist, int (*select)( const char * ), int (*compar)( const char **, const char ** ) ) );
42
43 #ifdef WIN32
44 # define stat _stati64
45 #endif
46
47 VLC_EXPORT( int, utf8_stat, ( const char *filename, struct stat *buf ) );
48 VLC_EXPORT( int, utf8_lstat, ( const char *filename, struct stat *buf ) );
49 VLC_EXPORT( int, utf8_mkdir, ( const char *filename ) );
50
51 VLC_EXPORT( int, utf8_vfprintf, ( FILE *stream, const char *fmt, va_list ap ) );
52 VLC_EXPORT( int, utf8_fprintf, ( FILE *, const char *, ... ) );
53
54 VLC_EXPORT( char *, EnsureUTF8, ( char * ) );
55 VLC_EXPORT( const char *, IsUTF8, ( const char * ) );
56
57 #ifdef WIN32
58 static inline char *FromWide (const wchar_t *wide)
59 {
60     size_t len = WideCharToMultiByte (CP_UTF8, 0, wide, -1, NULL, 0, NULL, NULL);
61     if (len == 0)
62         return NULL;
63
64     char *out = (char *)malloc (len);
65
66     WideCharToMultiByte (CP_UTF8, 0, wide, -1, out, len, NULL, NULL);
67     return out;
68 }
69 #endif
70
71 VLC_INTERNAL( char *, vlc_fix_readdir, ( const char * ) );
72 VLC_INTERNAL( vlc_bool_t, vlc_current_charset, ( char ** ) );
73
74 VLC_EXPORT( const char *, GetFallbackEncoding, ( void ) );
75
76 VLC_INTERNAL( double, i18n_strtod, ( const char *, char ** ) );
77 VLC_INTERNAL( double, i18n_atof, ( const char * ) );
78 VLC_EXPORT( double, us_strtod, ( const char *, char ** ) );
79 VLC_EXPORT( double, us_atof, ( const char * ) );
80
81 #endif