dvr: Try to autodetect the UTF-8 filesystem charset

This commit is contained in:
Jaroslav Kysela 2014-05-28 19:27:15 +02:00
parent 13aac5d3db
commit 1d7b92ea1f
3 changed files with 13 additions and 1 deletions

View file

@ -174,7 +174,7 @@ dvr_charset_update(dvr_config_t *cfg, const char *charset)
free(cfg->dvr_charset);
free(cfg->dvr_charset_id);
s = charset ? charset : "ASCII";
s = charset ? charset : intlconv_filesystem_charset();
id = intlconv_charset_id(s, 1, 1);
cfg->dvr_charset = strdup(s);
cfg->dvr_charset_id = id ? strdup(id) : NULL;

View file

@ -34,6 +34,16 @@ intlconv_done( void )
pthread_mutex_unlock(&intlconv_lock);
}
const char *
intlconv_filesystem_charset( void )
{
char *s = getenv("LANG");
if (s && strstr(s, ".utf8"))
return NULL;
/* be safe here */
return "ASCII";
}
static int
intlconv_cmp ( intlconv_cache_t *a, intlconv_cache_t *b )
{

View file

@ -23,6 +23,8 @@ extern const char *intlconv_charsets[];
void intlconv_init( void );
void intlconv_done( void );
const char *
intlconv_filesystem_charset( void );
char *
intlconv_charset_id( const char *charset,
int transil,