diff --git a/ChangeLog b/ChangeLog index fa8caad08..598bdc33b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,11 @@ WeeChat - Wee Enhanced Environment for Chat =========================================== -ChangeLog - 2007-01-07 +ChangeLog - 2007-01-08 Version 0.2.3 (under dev!): + * fixed iconv problem, causing truncated words when using iso locale * fixed topic scroll when topic has multi-bytes chars * fixed compilation problem with iconv under FreeBSD * fixed bugs with charset: now decodes/encodes nicks and channels in IRC diff --git a/src/common/util.c b/src/common/util.c index 4c31dafdc..97be2a545 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -200,10 +200,8 @@ weechat_iconv (char *from_code, char *to_code, char *string) #ifdef HAVE_ICONV iconv_t cd; - char *inbuf; + char *inbuf, *ptr_inbuf, *ptr_outbuf, *next_char; int done; - char *ptr_inbuf; - char *ptr_outbuf; size_t err, inbytesleft, outbytesleft; if (from_code && from_code[0] && to_code && to_code[0] @@ -236,7 +234,20 @@ weechat_iconv (char *from_code, char *to_code, char *string) done = 1; break; case EILSEQ: - ptr_inbuf[0] = '?'; + next_char = utf8_next_char (ptr_inbuf); + if (next_char) + { + inbytesleft -= next_char - ptr_inbuf; + ptr_inbuf = next_char; + } + else + { + inbytesleft--; + ptr_inbuf++; + } + ptr_outbuf[0] = '?'; + ptr_outbuf++; + outbytesleft--; break; } } diff --git a/weechat/ChangeLog b/weechat/ChangeLog index fa8caad08..598bdc33b 100644 --- a/weechat/ChangeLog +++ b/weechat/ChangeLog @@ -1,10 +1,11 @@ WeeChat - Wee Enhanced Environment for Chat =========================================== -ChangeLog - 2007-01-07 +ChangeLog - 2007-01-08 Version 0.2.3 (under dev!): + * fixed iconv problem, causing truncated words when using iso locale * fixed topic scroll when topic has multi-bytes chars * fixed compilation problem with iconv under FreeBSD * fixed bugs with charset: now decodes/encodes nicks and channels in IRC diff --git a/weechat/src/common/util.c b/weechat/src/common/util.c index 4c31dafdc..97be2a545 100644 --- a/weechat/src/common/util.c +++ b/weechat/src/common/util.c @@ -200,10 +200,8 @@ weechat_iconv (char *from_code, char *to_code, char *string) #ifdef HAVE_ICONV iconv_t cd; - char *inbuf; + char *inbuf, *ptr_inbuf, *ptr_outbuf, *next_char; int done; - char *ptr_inbuf; - char *ptr_outbuf; size_t err, inbytesleft, outbytesleft; if (from_code && from_code[0] && to_code && to_code[0] @@ -236,7 +234,20 @@ weechat_iconv (char *from_code, char *to_code, char *string) done = 1; break; case EILSEQ: - ptr_inbuf[0] = '?'; + next_char = utf8_next_char (ptr_inbuf); + if (next_char) + { + inbytesleft -= next_char - ptr_inbuf; + ptr_inbuf = next_char; + } + else + { + inbytesleft--; + ptr_inbuf++; + } + ptr_outbuf[0] = '?'; + ptr_outbuf++; + outbytesleft--; break; } }