1 /*****************************************************************************
2 * charset.c: Locale's character encoding stuff.
3 *****************************************************************************
4 * See also unicode.c for Unicode to locale conversion helpers.
6 * Copyright (C) 2003-2008 the VideoLAN team
8 * Authors: Christophe Massiot
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
30 #include <vlc_common.h>
45 #include <vlc_charset.h>
47 char *vlc_fix_readdir( const char *psz_string )
50 vlc_iconv_t hd = vlc_iconv_open( "UTF-8", "UTF-8-MAC" );
52 if (hd != (vlc_iconv_t)(-1))
54 const char *psz_in = psz_string;
55 size_t i_in = strlen(psz_in);
56 size_t i_out = i_in * 2;
57 char *psz_utf8 = malloc(i_out + 1);
58 char *psz_out = psz_utf8;
60 size_t i_ret = vlc_iconv (hd, &psz_in, &i_in, &psz_out, &i_out);
62 if( i_ret == (size_t)(-1) || i_in )
65 return strdup( psz_string );
72 return strdup( psz_string );
77 * us_strtod() has the same prototype as ANSI C strtod() but it uses the
78 * POSIX/C decimal format, regardless of the current numeric locale.
80 double us_strtod( const char *str, char **end )
82 locale_t loc = newlocale (LC_NUMERIC_MASK, "C", NULL);
83 locale_t oldloc = uselocale (loc);
84 double res = strtod (str, end);
86 if (loc != (locale_t)0)
95 * us_atof() has the same prototype as ANSI C atof() but it expects a dot
96 * as decimal separator, regardless of the system locale.
98 double us_atof( const char *str )
100 return us_strtod( str, NULL );