/* * guess default encoding of subtitles */ const char *xine_guess_spu_encoding(void) { char *lang = _get_lang(); if (lang) { const lang_locale_t *llocale; char *lg, *enc; lg = strdup(lang); if ((enc = strchr(lg, '.'))) *enc = '\0'; llocale = _get_first_lang_locale(lg); free(lg); if (llocale && llocale->spu_encoding) return llocale->spu_encoding; } return "iso-8859-1"; }
/** * get encoding of current locale */ extern char * xutil_system_encoding(void) { char *codeset = NULL; #ifdef HAVE_LANGINFO_CODESET codeset = nl_langinfo(CODESET); #endif /* * guess locale codeset according to shell variables * when nl_langinfo(CODESET) isn't available or workig */ if (!codeset || strstr(codeset, "ANSI") != 0) { char *lang = _get_lang(); codeset = NULL; if(lang) { char *lg, *enc, *mod; lg = strdup(lang); if((enc = strchr(lg, '.')) && (strlen(enc) > 1)) { enc++; if((mod = strchr(enc, '@'))) *mod = '\0'; codeset = strdup(enc); } else { const lang_locale_t *llocale = _get_first_lang_locale(lg); if(llocale && llocale->encoding) codeset = strdup(llocale->encoding); } free(lg); } } else codeset = strdup(codeset); return codeset; }