vlc_charset.h File Reference

This files handles locale conversions in vlc. More...

Include dependency graph for vlc_charset.h:

Go to the source code of this file.

Defines

#define VLC_CHARSET_H   1

Functions

void LocaleFree (const char *)
 Releases (if needed) a localized or uniformized string.
char * FromLocale (const char *)
 Converts a string from the system locale character encoding to UTF-8.
char * FromLocaleDup (const char *)
 converts a string from the system locale character encoding to utf-8, the result is always allocated on the heap.
char * ToLocale (const char *)
 ToLocale: converts an UTF-8 string to local system encoding.
char * ToLocaleDup (const char *)
 converts a string from UTF-8 to the system locale character encoding, the result is always allocated on the heap.
int utf8_open (const char *filename, int flags,...)
 Opens a system file handle.
FILE * utf8_fopen (const char *filename, const char *mode)
 Opens a FILE pointer.
DIRutf8_opendir (const char *dirname)
 Opens a DIR pointer.
char * utf8_readdir (DIR *dir)
 Reads the next file name from an open directory.
int utf8_loaddir (DIR *dir, char ***namelist, int(*select)(const char *), int(*compar)(const char **, const char **))
 Does the same as utf8_scandir(), but takes an open directory pointer instead of a directory path.
int utf8_scandir (const char *dirname, char ***namelist, int(*select)(const char *), int(*compar)(const char **, const char **))
 Selects file entries from a directory, as GNU C scandir().
int utf8_mkdir (const char *filename, mode_t mode)
 Creates a directory using UTF-8 paths.
int utf8_unlink (const char *filename)
 Removes a file.
int utf8_rename (const char *, const char *)
 Moves a file atomically.
int utf8_stat (const char *filename, struct stat *buf)
 Finds file/inode informations, as stat().
int utf8_lstat (const char *filename, struct stat *buf)
 Finds file/inode informations, as lstat().
int utf8_vfprintf (FILE *stream, const char *fmt, va_list ap)
 Formats an UTF-8 string as vfprintf(), then print it, with appropriate conversion to local encoding.
int utf8_fprintf (FILE *, const char *,...)
 Formats an UTF-8 string as fprintf(), then print it, with appropriate conversion to local encoding.
int utf8_mkstemp (char *)
char * EnsureUTF8 (char *)
 Replaces invalid/overlong UTF-8 sequences with question marks.
const char * IsUTF8 (const char *)
 Checks whether a string is a valid UTF-8 byte sequence.
static char * FromLatin1 (const char *latin)
 Converts a nul-terminated string from ISO-8859-1 to UTF-8.
const char * GetFallbackEncoding (void)
 GetFallbackEncoding() suggests an encoding to be used for non UTF-8 text files accord to the system's local settings.
double us_strtod (const char *, char **)
 us_strtod() has the same prototype as ANSI C strtod() but it uses the POSIX/C decimal format, regardless of the current numeric locale.
float us_strtof (const char *, char **)
 us_strtof() has the same prototype as ANSI C strtof() but it uses the POSIX/C decimal format, regardless of the current numeric locale.
double us_atof (const char *)
 us_atof() has the same prototype as ANSI C atof() but it expects a dot as decimal separator, regardless of the system locale.
int us_asprintf (char **, const char *,...)
 us_asprintf() has the same prototype as asprintf(), but doesn't use the system locale.


Detailed Description

This files handles locale conversions in vlc.


Define Documentation

#define VLC_CHARSET_H   1


Function Documentation

char* EnsureUTF8 ( char *  str  ) 

Replaces invalid/overlong UTF-8 sequences with question marks.

Note that it is not possible to convert from Latin-1 to UTF-8 on the fly, so we don't try that, even though it would be less disruptive.

Returns:
str if it was valid UTF-8, NULL if not.

References CheckUTF8().

Referenced by AddItem(), CdTextParse(), decode_URI(), Demux(), Filter(), FixUTF8(), HandleMeta(), InputMetaUser(), KeyToUTF8(), LoadChapterApple(), LoadChapterGpac(), MakeAttribute(), MemoryReadString1(), mvnprintw(), ParseAPEvXTag(), ParsePicture(), ParseSDP(), ParseText(), ReadICYMeta(), Request(), StoreString(), StreamReadString2(), Subtitle(), test(), and vorbis_ParseComment().

static char* FromLatin1 ( const char *  latin  )  [inline, static]

Converts a nul-terminated string from ISO-8859-1 to UTF-8.

References c, gen_builder::str, and utf8.

char* FromLocale ( const char *  locale  ) 

Converts a string from the system locale character encoding to UTF-8.

Parameters:
locale nul-terminated string to convert
Returns:
a nul-terminated UTF-8 string, or NULL in case of error. To avoid memory leak, you have to pass the result to LocaleFree() when it is no longer needed.

References locale_fast().

Referenced by config_GetAppDir(), GetDir(), and sFromLocale().

char* FromLocaleDup ( const char *  locale  ) 

converts a string from the system locale character encoding to utf-8, the result is always allocated on the heap.

Parameters:
locale nul-terminated string to convert
Returns:
a nul-terminated utf-8 string, or null in case of error. The result must be freed using free() - as with the strdup() function.

References locale_dup().

Referenced by __config_LoadConfigFile(), config_GetHomeDir(), config_GetTypeDir(), Import_M3U(), KeyToUTF8(), and ReloadWaveoutDevices().

const char* GetFallbackEncoding ( void   ) 

GetFallbackEncoding() suggests an encoding to be used for non UTF-8 text files accord to the system's local settings.

It is only a best guess.

References FindFallbackEncoding(), and getenv().

Referenced by OpenDecoder().

const char* IsUTF8 ( const char *  str  ) 

Checks whether a string is a valid UTF-8 byte sequence.

Parameters:
str nul-terminated string to be checked
Returns:
str if it was valid UTF-8, NULL if not.

References CheckUTF8().

Referenced by IsSDPString(), ParseText(), and test().

void LocaleFree ( const char *  str  ) 

char* ToLocale ( const char *  utf8  ) 

ToLocale: converts an UTF-8 string to local system encoding.

Parameters:
utf8 nul-terminated string to be converted
Returns:
a nul-terminated string, or NULL in case of error. To avoid memory leak, you have to pass the result to LocaleFree() when it is no longer needed.

References locale_fast().

Referenced by gnutls_ServerAddCA(), gnutls_ServerAddCRL(), mvnprintw(), Open(), OpenServer(), ReadMeta(), sToLocale(), utf8_mkdir(), utf8_open(), utf8_opendir(), utf8_rename(), utf8_statEx(), utf8_unlink(), vlc_getaddrinfo(), and WriteMeta().

char* ToLocaleDup ( const char *  utf8  ) 

converts a string from UTF-8 to the system locale character encoding, the result is always allocated on the heap.

Parameters:
utf8 nul-terminated string to convert
Returns:
a nul-terminated string, or null in case of error. The result must be freed using free() - as with the strdup() function.

References locale_dup().

Referenced by Open(), utf8_vasprintf(), and vcd_Open().

int us_asprintf ( char **  ,
const char *  ,
  ... 
)

us_asprintf() has the same prototype as asprintf(), but doesn't use the system locale.

References freelocale(), LC_NUMERIC_MASK, newlocale(), uselocale(), and vasprintf().

Referenced by UpdateVolume().

double us_atof ( const char *   ) 

us_atof() has the same prototype as ANSI C atof() but it expects a dot as decimal separator, regardless of the system locale.

References us_strtod().

Referenced by __config_ChainParse(), __config_LoadCmdLine(), __var_Command(), main(), Open(), OpenDemux(), var_OptionParse(), and vout_IntfInit().

double us_strtod ( const char *  ,
char **   
)

us_strtod() has the same prototype as ANSI C strtod() but it uses the POSIX/C decimal format, regardless of the current numeric locale.

References freelocale(), LC_NUMERIC_MASK, newlocale(), and uselocale().

Referenced by main(), ParseMicroDvd(), ParseMPSub(), RtspCallback(), and us_atof().

float us_strtof ( const char *  ,
char **   
)

us_strtof() has the same prototype as ANSI C strtof() but it uses the POSIX/C decimal format, regardless of the current numeric locale.

References freelocale(), LC_NUMERIC_MASK, newlocale(), strtof(), and uselocale().

Referenced by BandsCallback(), and ParseMRL().

FILE* utf8_fopen ( const char *  filename,
const char *  mode 
)

Opens a FILE pointer.

Parameters:
filename file path, using UTF-8 encoding
mode fopen file open mode
Returns:
NULL on error, an open FILE pointer on success.

References utf8_open().

Referenced by ACL_LoadFile(), ArtCallback(), config_OpenConfigFile(), GetSCIData(), HttpCallback(), ImageWriteUrl(), libvlc_InternalInit(), Open(), OpenVCDImage(), osd_parser_simpleOpen(), ParseDirectory(), playlist_Export(), playlist_SaveArt(), ReadPasswordFile(), ReadUserKey(), Start(), svg_GetTemplate(), Trigger(), UnpackFromFile(), vout_snapshot_SaveImage(), and WriteUserKey().

int utf8_fprintf ( FILE *  ,
const char *  ,
  ... 
)

Formats an UTF-8 string as fprintf(), then print it, with appropriate conversion to local encoding.

References utf8_vfprintf().

Referenced by Export_M3U(), Help(), libvlc_InternalInit(), ListModules(), print_help_on_full_help(), print_help_section(), PrintMsg(), Usage(), and Version().

int utf8_loaddir ( DIR dir,
char ***  namelist,
int(*)(const char *)  select,
int(*)(const char **, const char **)  compar 
)

Does the same as utf8_scandir(), but takes an open directory pointer instead of a directory path.

References dummy_select(), i, rewinddir, and utf8_readdir().

Referenced by utf8_scandir().

int utf8_lstat ( const char *  filename,
struct stat *  buf 
)

Finds file/inode informations, as lstat().

Consider using fstat() instead, if possible.

Parameters:
filename UTF-8 file path

References utf8_statEx().

Referenced by gnutls_Addx509Directory().

int utf8_mkdir ( const char *  dirname,
mode_t  mode 
)

Creates a directory using UTF-8 paths.

Parameters:
dirname a UTF-8 string with the name of the directory that you want to create.
mode directory permissions
Returns:
0 on success, -1 on error (see errno).

References LocaleFree(), and ToLocale().

Referenced by ArtCacheCreateDir(), config_CreateDir(), GetTmpPath(), gnutls_Addx509Directory(), and OpenClient().

int utf8_mkstemp ( char *   ) 

References i, utf8_open(), and vlc_rand_bytes().

int utf8_open ( const char *  filename,
int  flags,
  ... 
)

Opens a system file handle.

Parameters:
filename file path to open (with UTF-8 encoding)
flags open() flags, see the C library open() documentation
Returns:
a file handle on success, -1 on error (see errno).
Note:
Contrary to standard open(), this function returns file handles with the close-on-exec flag enabled.

References LocaleFree(), and ToLocale().

Referenced by CAMOpen(), Create(), DMXSetFilter(), DVROpen(), Filter(), FrontendOpen(), gnutls_Addx509File(), ioctl_Open(), Open(), open_file(), OpenAudioDev(), OpenAudioDevOss(), OpenDecoderCommon(), OpenDisplay(), OpenVCDImage(), OpenVideoDev(), ProbeAudioDevOss(), ProbeDVD(), ProbeVideoDev(), SaveConfigFile(), utf8_fopen(), utf8_mkstemp(), and vlc_rand_init().

DIR* utf8_opendir ( const char *  dirname  ) 

Opens a DIR pointer.

Parameters:
dirname UTF-8 representation of the directory name
Returns:
a pointer to the DIR struct, or NULL in case of error. Release with standard closedir().

References LocaleFree(), opendir, and ToLocale().

Referenced by Block(), gnutls_Addx509Directory(), input_CreateFilename(), Open(), ParseDirectory(), playlist_FindArtInCache(), ReadDir(), utf8_scandir(), vlclua_opendir(), and vout_snapshot_SaveImage().

char* utf8_readdir ( DIR dir  ) 

Reads the next file name from an open directory.

Parameters:
dir The directory that is being read
Returns:
a UTF-8 string of the directory entry. Use free() to free this memory.

References dirent::d_name, readdir, and vlc_fix_readdir().

Referenced by Block(), gnutls_Addx509Directory(), ParseDirectory(), playlist_FindArtInCache(), ReadDir(), utf8_loaddir(), and vlclua_opendir().

int utf8_rename ( const char *  oldpath,
const char *  newpath 
)

Moves a file atomically.

This only works within a single file system.

Parameters:
oldpath path to the file before the move
newpath intended path to the file after the move
Returns:
A 0 return value indicates success. A -1 return value indicates an error, and an error code is stored in errno

References LocaleFree(), and ToLocale().

Referenced by SaveConfigFile().

int utf8_scandir ( const char *  dirname,
char ***  namelist,
int(*)(const char *)  select,
int(*)(const char **, const char **)  compar 
)

Selects file entries from a directory, as GNU C scandir().

Parameters:
dirname UTF-8 diretory path
pointer [OUT] pointer set, on succesful completion, to the address of a table of UTF-8 filenames. All filenames must be freed with free(). The table itself must be freed with free() as well.
Returns:
How many file names were selected (possibly 0), or -1 in case of error.

References closedir, utf8_loaddir(), and utf8_opendir().

Referenced by Load(), mvar_FileSetNew(), subtitles_Detect(), and vlclua_scripts_batch_execute().

int utf8_stat ( const char *  filename,
struct stat *  buf 
)

Finds file/inode informations, as stat().

Consider using fstat() instead, if possible.

Parameters:
filename UTF-8 file path

References utf8_statEx().

Referenced by CheckFileList(), FindMeta(), FindPathBase(), GetTmpPath(), InputGetExtraFilesPattern(), ioctl_Open(), ThemeLoader::load(), mvar_FileSetNew(), ParseDirectory(), playlist_MLLoad(), playlist_SaveArt(), ReadDir(), Run(), SubtitleAdd(), subtitles_Detect(), vlclua_stat(), and vout_snapshot_SaveImage().

int utf8_unlink ( const char *  filename  ) 

Removes a file.

Parameters:
filename a UTF-8 string with the name of the file you want to delete.
Returns:
A 0 return value indicates success. A -1 return value indicates an error, and an error code is stored in errno

References LocaleFree(), and ToLocale().

Referenced by Close(), OutputStart(), and SaveConfigFile().

int utf8_vfprintf ( FILE *  stream,
const char *  fmt,
va_list  ap 
)

Formats an UTF-8 string as vfprintf(), then print it, with appropriate conversion to local encoding.

References gen_builder::str, and utf8_vasprintf().

Referenced by __msg_rc(), and utf8_fprintf().


Generated on Sat Nov 21 08:05:26 2009 for VLC by  doxygen 1.5.6