|
发表于 2005-12-25 23:01:31
|
显示全部楼层
Dammit! 可能是某些与samba相关的操作。我碰到的情况是xine-lib支持samba协议,有个插件 xineplug_inp_smb.so,而totem使用libxine,结果totem老是被重置到英文 locale,同样也影响了 Nautilus。去掉 xineplug_inp_smb.so 不加载,正常。
查了一下samba的源代码,发现了下面的某位牛人写的代码,在samba源代码的 source/lib/charcnv.c 文件中:
[code:1]
/**
* Return the name of a charset to give to iconv().
**/
static const char *charset_name(charset_t ch)
{
const char *ret = NULL;
if (ch == CH_UCS2) ret = "UTF-16LE";
else if (ch == CH_UNIX) ret = lp_unix_charset();
else if (ch == CH_DOS) ret = lp_dos_charset();
else if (ch == CH_DISPLAY) ret = lp_display_charset();
else if (ch == CH_UTF8) ret = "UTF8";
#if defined(HAVE_NL_LANGINFO) && defined(CODESET)
if (ret && !strcmp(ret, "LOCALE")) {
const char *ln = NULL;
#ifdef HAVE_SETLOCALE
setlocale(LC_ALL, "");
#endif
ln = nl_langinfo(CODESET);
if (ln) {
/* Check whether the charset name is supported
by iconv */
smb_iconv_t handle = smb_iconv_open(ln,"UCS-2LE");
if (handle == (smb_iconv_t) -1) {
DEBUG(5,("Locale charset '%s' unsupported, using ASCII instead\n", ln));
ln = NULL;
} else {
DEBUG(5,("Substituting charset '%s' for LOCALE\n", ln));
smb_iconv_close(handle);
}
}
ret = ln;
}
#ifdef HAVE_SETLOCALE
/* We set back the locale to C to get ASCII-compatible toupper/lower functions.
For now we do not need any other POSIX localisations anyway. When we should
really need localized string functions one day we need to write our own
ascii_tolower etc.
*/
setlocale(LC_ALL, "C");
#endif
#endif
if (!ret || !*ret) ret = "ASCII";
return ret;
}
[/code:1]
上面两个 setlocale 都不该用,特别是第二个使用的有问题。
这位牛人似乎考虑到了未来的某件事,结果一不小心对现在造成了影响。 |
|