vlc_charset.h 3.47 KB
Newer Older
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 11 12 13
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
14
 *
15 16 17 18 19 20 21
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
Antoine Cellerier's avatar
Antoine Cellerier committed
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 24
 *****************************************************************************/

25 26 27 28
#if !defined( __LIBVLC__ )
  #error You are not libvlc or one of its plugins. You cannot include this file
#endif

29 30 31
#ifndef __VLC_CHARSET_H
#define __VLC_CHARSET_H 1

32
#include <stdarg.h>
33
#include <sys/types.h>
34
#include <dirent.h>
35

36 37
VLC_EXPORT( void, LocaleFree, ( const char * ) );
VLC_EXPORT( char *, FromLocale, ( const char * ) );
38
VLC_EXPORT( char *, FromLocaleDup, ( const char * ) );
39
VLC_EXPORT( char *, ToLocale, ( const char * ) );
40

41
/* TODO: move all of this to "vlc_fs.h" or something like that */
42
VLC_EXPORT( int, utf8_open, ( const char *filename, int flags, mode_t mode ) );
43
VLC_EXPORT( FILE *, utf8_fopen, ( const char *filename, const char *mode ) );
44
VLC_EXPORT( DIR *, utf8_opendir, ( const char *dirname ) );
45
VLC_EXPORT( char *, utf8_readdir, ( DIR *dir ) );
46
VLC_EXPORT( int, utf8_loaddir, ( DIR *dir, char ***namelist, int (*select)( const char * ), int (*compar)( const char **, const char ** ) ) );
47
VLC_EXPORT( int, utf8_scandir, ( const char *dirname, char ***namelist, int (*select)( const char * ), int (*compar)( const char **, const char ** ) ) );
48
VLC_EXPORT( int, utf8_mkdir, ( const char *filename, mode_t mode ) );
49
VLC_EXPORT( int, utf8_unlink, ( const char *filename ) );
50 51 52 53 54 55 56

#ifdef WIN32
# define stat _stati64
#endif

VLC_EXPORT( int, utf8_stat, ( const char *filename, struct stat *buf ) );
VLC_EXPORT( int, utf8_lstat, ( const char *filename, struct stat *buf ) );
57

58
VLC_EXPORT( int, utf8_vfprintf, ( FILE *stream, const char *fmt, va_list ap ) );
59
VLC_EXPORT( int, utf8_fprintf, ( FILE *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
60

61
VLC_EXPORT( char *, EnsureUTF8, ( char * ) );
62 63
VLC_EXPORT( const char *, IsUTF8, ( const char * ) );

64
#ifdef WIN32
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
65 66 67 68 69 70
static inline char *FromWide (const wchar_t *wide)
{
    size_t len = WideCharToMultiByte (CP_UTF8, 0, wide, -1, NULL, 0, NULL, NULL);
    if (len == 0)
        return NULL;

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
71
    char *out = (char *)malloc (len);
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
72 73 74 75

    WideCharToMultiByte (CP_UTF8, 0, wide, -1, out, len, NULL, NULL);
    return out;
}
76
#endif
77

78
VLC_INTERNAL( char *, vlc_fix_readdir, ( const char * ) );
79
VLC_INTERNAL( bool, vlc_current_charset, ( char ** ) );
80

Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
81 82
VLC_EXPORT( const char *, GetFallbackEncoding, ( void ) );

83 84
VLC_INTERNAL( double, i18n_strtod, ( const char *, char ** ) );
VLC_INTERNAL( double, i18n_atof, ( const char * ) );
85
VLC_EXPORT( double, us_strtod, ( const char *, char ** ) );
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
86
VLC_EXPORT( double, us_atof, ( const char * ) );
87

88
#endif