Commit b01009b8 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

Look for Byte Order Mark (UTF-8 only) while loading config file.

If present, assume everything is UTF-8 (obviously);
if not, assume locale charset.
parent f45f1573
......@@ -816,6 +816,17 @@ int __config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name )
/* The config file is organized in sections, one per module. Look for
* the interesting section ( a section is of the form [foo] ) */
fseek( file, 0L, SEEK_SET );
/* Look for UTF-8 Byte Order Mark */
char * (*convert) (const char *) = FromLocaleDup;
char bom[3];
if ((fread (bom, 1, 3, file) == 3)
&& (memcmp (bom, "\xEF\xBB\xBF", 3) == 0))
convert = strdup;
else
rewind (file); // no BOM, rewind
while( fgets( line, 1024, file ) )
{
if( (line[0] == '[')
......@@ -916,7 +927,7 @@ int __config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name )
free( p_item->psz_value );
p_item->psz_value = *psz_option_value ?
strdup( psz_option_value ) : NULL;
convert( psz_option_value ) : NULL;
if( p_item->psz_value_saved )
free( p_item->psz_value_saved );
......@@ -925,7 +936,7 @@ int __config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name )
(p_item->psz_value && p_item->psz_value_orig &&
strcmp(p_item->psz_value,p_item->psz_value_orig)))
p_item->psz_value_saved = p_item->psz_value ?
strdup( p_item->psz_value ) : NULL;
convert( p_item->psz_value ) : NULL;
vlc_mutex_unlock( p_item->p_lock );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment