summaryrefslogtreecommitdiff
path: root/src/core/recode.c
diff options
context:
space:
mode:
authorValentin Batz <senneth@irssi.org>2006-07-25 11:02:10 +0000
committervb <vb@dbcabf3a-b0e7-0310-adc4-f8d773084564>2006-07-25 11:02:10 +0000
commitda965109edfc988262d962bca2b9d6a6e80ecad5 (patch)
tree15d476eb27461fd77866bada90374d24329e39b5 /src/core/recode.c
parent7602b7eff585bae510d52d6757117637f3b89c7f (diff)
downloadirssi-da965109edfc988262d962bca2b9d6a6e80ecad5.zip
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
Diffstat (limited to 'src/core/recode.c')
-rw-r--r--src/core/recode.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/core/recode.c b/src/core/recode.c
index 75a1c127..5bf05f9d 100644
--- a/src/core/recode.c
+++ b/src/core/recode.c
@@ -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);
- str_is_utf8 = g_utf8_validate(str, len, NULL);
+ /* 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);