mirror of
https://github.com/moparisthebest/hexchat
synced 2024-11-22 09:12:22 -05:00
Don't convert the result of g_get_user_name / g_get_real_name from locale to utf-8 on Windows. They return utf-8 already.
This commit is contained in:
parent
dc27640265
commit
e4413e0178
@ -613,16 +613,19 @@ convert_with_fallback (const char *str, const char *fallback)
|
|||||||
{
|
{
|
||||||
char *utf;
|
char *utf;
|
||||||
|
|
||||||
utf = g_locale_to_utf8 (str, -1, 0, 0, 0);
|
#ifndef WIN32
|
||||||
|
/* On non-Windows, g_get_user_name and g_get_real_name return a string in system locale, so convert it to utf-8. */
|
||||||
|
utf = g_locale_to_utf8 (str, -1, NULL, NULL, 0);
|
||||||
|
|
||||||
|
g_free (str);
|
||||||
|
|
||||||
|
/* The returned string is NULL if conversion from locale to utf-8 failed for any reason. Return the fallback. */
|
||||||
if (!utf)
|
if (!utf)
|
||||||
{
|
utf = g_strdup (fallback);
|
||||||
/* this can happen if CHARSET envvar is set wrong */
|
#else
|
||||||
/* maybe it's already utf8 (breakage!) */
|
/* On Windows, they return a string in utf-8, so don't do anything to it. The fallback isn't needed. */
|
||||||
if (!g_utf8_validate (str, -1, NULL))
|
utf = str;
|
||||||
utf = g_strdup (fallback);
|
#endif
|
||||||
else
|
|
||||||
utf = g_strdup (str);
|
|
||||||
}
|
|
||||||
|
|
||||||
return utf;
|
return utf;
|
||||||
}
|
}
|
||||||
@ -739,13 +742,13 @@ load_default_config(void)
|
|||||||
|
|
||||||
username = g_get_user_name ();
|
username = g_get_user_name ();
|
||||||
if (!username)
|
if (!username)
|
||||||
username = "root";
|
username = g_strdup ("root");
|
||||||
|
|
||||||
/* We hid Real name from the Network List, so don't use the user's name unnoticeably */
|
/* We hid Real name from the Network List, so don't use the user's name unnoticeably */
|
||||||
/* realname = g_get_real_name ();
|
/* realname = g_get_real_name ();
|
||||||
if ((realname && realname[0] == 0) || !realname)
|
if ((realname && realname[0] == 0) || !realname)
|
||||||
realname = username; */
|
realname = username; */
|
||||||
realname = "realname";
|
realname = g_strdup ("realname");
|
||||||
|
|
||||||
username = convert_with_fallback (username, "username");
|
username = convert_with_fallback (username, "username");
|
||||||
realname = convert_with_fallback (realname, "realname");
|
realname = convert_with_fallback (realname, "realname");
|
||||||
|
Loading…
Reference in New Issue
Block a user