1
0
mirror of https://github.com/irssi/irssi.git synced 2024-09-29 04:45:57 -04:00

Don't assume that 7bit ascii strings are encoded in UTF-8, only validate the strings when they contain octest with highest bit set. (patch by Mikko Rauhala)

fixes http://bugs.irssi.org/index.php?do=details&id=392

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4300 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Valentin Batz 2006-07-25 11:02:10 +00:00 committed by vb
parent 7602b7eff5
commit da965109ed

View File

@ -80,6 +80,7 @@ char *recode_in(const SERVER_REC *server, const char *str, const char *target)
char *tagtarget = NULL;
gboolean term_is_utf8, str_is_utf8, translit, recode, autodetect;
int len;
int i;
if (!str)
return NULL;
@ -90,7 +91,14 @@ char *recode_in(const SERVER_REC *server, const char *str, const char *target)
len = strlen(str);
/* Only validate for UTF-8 if an 8-bit encoding. */
str_is_utf8 = 0;
for (i = 0; i < len; ++i) {
if (str[i] & 0x80) {
str_is_utf8 = g_utf8_validate(str, len, NULL);
break;
}
}
translit = settings_get_bool("recode_transliterate");
autodetect = settings_get_bool("recode_autodetect_utf8");
term_is_utf8 = recode_get_charset(&to);