From owner-freebsd-ports-bugs@FreeBSD.ORG Wed Oct 8 03:10:13 2003 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 347BC16A4B3 for ; Wed, 8 Oct 2003 03:10:13 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8956043FEA for ; Wed, 8 Oct 2003 03:10:11 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h98AABFY088748 for ; Wed, 8 Oct 2003 03:10:11 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h98AAB9A088747; Wed, 8 Oct 2003 03:10:11 -0700 (PDT) (envelope-from gnats) Resent-Date: Wed, 8 Oct 2003 03:10:11 -0700 (PDT) Resent-Message-Id: <200310081010.h98AAB9A088747@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Cheng-Lung Sung Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 801A516A4B3 for ; Wed, 8 Oct 2003 03:09:01 -0700 (PDT) Received: from mail.dragon2.net (sungsung.csie.nctu.edu.tw [140.113.215.201]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2252743FD7 for ; Wed, 8 Oct 2003 03:08:59 -0700 (PDT) (envelope-from clsung@dragon2.net) Received: from localhost (unknown [127.0.0.1]) by mail.dragon2.net (Postfix) with ESMTP id 956B1155A5; Wed, 8 Oct 2003 10:10:29 +0000 (GMT) Received: from mail.dragon2.net ([127.0.0.1])port 10024) with ESMTP id 02591-01; Wed, 8 Oct 2003 18:10:28 +0800 (CST) Received: by mail.dragon2.net (Postfix, from userid 1022) id BB51415561; Wed, 8 Oct 2003 18:01:57 +0800 (CST) Message-Id: <20031008100157.BB51415561@mail.dragon2.net> Date: Wed, 8 Oct 2003 18:01:57 +0800 (CST) From: Cheng-Lung Sung To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 cc: Cheng-Lung Sung Subject: ports/57734: [patch] cicq utf8 chars display problem. X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Cheng-Lung Sung List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Oct 2003 10:10:13 -0000 >Number: 57734 >Category: ports >Synopsis: [patch] cicq utf8 chars display problem. >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: maintainer-update >Submitter-Id: current-users >Arrival-Date: Wed Oct 08 03:10:10 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Cheng-Lung Sung >Release: FreeBSD 4.8-RELEASE-p13 i386 >Organization: Freebsd @ Taiwan >Environment: System: FreeBSD sungsung.csie.nctu.edu.tw 4.8-RELEASE-p13 FreeBSD 4.8-RELEASE-p13 #3: Wed Oct 8 07:32:16 CST 2003 root@sungsung.csie.nctu.edu.tw:/usr/obj/usr/src/sys/SUNGSUNG i386 must have iconv library >Description: fix original bugs, such as utf8/utf-8, MSN nickname refresh problem >How-To-Repeat: Original program can't send/receive non-ASCII chars correctly in MSN/Yahho. this patch can fix that. Also note that original config file has problem in writing default charset setting to file. >Fix: diff -ruN /usr/ports/net/centericq/files/patch-icqconf.cc /home/AlanSung/centericq/files/patch-icqconf.cc --- /usr/ports/net/centericq/files/patch-icqconf.cc Thu Jan 1 08:00:00 1970 +++ /home/AlanSung/centericq/files/patch-icqconf.cc Wed Oct 8 17:45:50 2003 @@ -0,0 +1,11 @@ +--- src/icqconf.cc.orig Wed Oct 1 08:27:45 2003 ++++ src/icqconf.cc Wed Oct 8 17:28:21 2003 +@@ -270,7 +270,7 @@ + if(getantispam()) f << "antispam" << endl; + if(getmailcheck()) f << "mailcheck" << endl; + if(getaskaway()) f << "askaway" << endl; +- f << "defcharset" << getdefcharset() << endl; ++ f << "defcharset\t" << getdefcharset() << endl; + + param = ""; + for(protocolname pname = icq; pname != protocolname_size; (int) pname += 1) diff -ruN /usr/ports/net/centericq/files/patch-msnhook.cc /home/AlanSung/centericq/files/patch-msnhook.cc --- /usr/ports/net/centericq/files/patch-msnhook.cc Wed Oct 8 08:31:51 2003 +++ /home/AlanSung/centericq/files/patch-msnhook.cc Wed Oct 8 17:45:25 2003 @@ -1,29 +1,20 @@ --- src/hooks/msnhook.cc.orig Tue Sep 30 19:38:43 2003 -+++ src/hooks/msnhook.cc Tue Oct 7 10:20:29 2003 -@@ -33,6 +33,7 @@ - #include "accountmanager.h" - #include "eventmanager.h" - #include "imlogger.h" -+#include "utf8conv.h" - #include "connwrap.h" - - #include "msn_bittybits.h" -@@ -248,7 +249,8 @@ ++++ src/hooks/msnhook.cc Wed Oct 8 17:44:13 2003 +@@ -248,7 +248,7 @@ } icqcontact *c = clist.get(ev.getcontact()); - text = siconv(text, conf.getrussian(msn) ? "koi8-u" : conf.getdefcharset(), "utf8"); -+// text = siconv(text, conf.getrussian(msn) ? "koi8-u" : conf.getdefcharset(), "utf8"); -+ text = StrToUtf8(text); ++ text = siconv(text, conf.getrussian(msn) ? "koi8-u" : conf.getdefcharset(), "utf-8"); if(c) if(c->getstatus() != offline || !c->inlist()) { -@@ -378,11 +380,11 @@ +@@ -378,11 +378,11 @@ void msnhook::checkfriendly(icqcontact *c, const string friendlynick, bool forcefetch) { string oldnick = c->getnick(); - string newnick = unmime(friendlynick); -+ string newnick = Utf8ToStr(unmime(friendlynick)); ++ string newnick = siconv(unmime(friendlynick), "utf-8", conf.getrussian(msn) ? "koi8-u" : conf.getdefcharset()); c->setnick(newnick); @@ -32,153 +23,12 @@ c->setdispnick(newnick); face.relaxedupdate(); } -@@ -602,7 +604,8 @@ +@@ -602,7 +602,7 @@ mhook.checkinlist(ic); - string text = siconv(msg->body, "utf8", conf.getrussian(msn) ? "koi8-u" : conf.getdefcharset()); -+// string text = siconv(msg->body, "utf8", conf.getrussian(msn) ? "koi8-u" : conf.getdefcharset()); -+ string text = Utf8ToStr(msg->body); ++ string text = siconv(msg->body, "utf-8", conf.getrussian(msn) ? "koi8-u" : conf.getdefcharset()); em.store(immessage(ic, imevent::incoming, text)); } -@@ -779,5 +782,139 @@ - log(string("[OUT] ") + buf); - } - } -+ -+#if HAVE_ICONV_H -+int safe_iconv( iconv_t handle, const char **inbuf, size_t *inbytesleft, -+ char **outbuf, size_t *outbytesleft) -+{ -+ int ret; -+ while (*inbytesleft) { -+ ret = iconv( handle, inbuf, inbytesleft, -+ outbuf, outbytesleft); -+ if (!*inbytesleft || !*outbytesleft) -+ return ret; -+ /*got invalid seq - so replace it with '?' */ -+ **outbuf = '?'; (*outbuf)++; (*outbytesleft)--; -+ (*inbuf)++; (*inbytesleft)--; -+ } -+ return ret; -+} -+ -+const char* guess_current_locale_charset() -+{ -+ char *lang, *ch; -+ /* Return previously learned charset */ -+ if (loc_charset[0]) -+ return loc_charset; -+ -+ lang = getenv("LANG"); -+ if (!lang) { -+ strcpy( loc_charset, DEFAULT_CHARSET ); -+ return loc_charset; -+ }; -+ ch = strrchr( lang, '.' ); -+ if (!ch) -+ strcpy( loc_charset, DEFAULT_CHARSET ); -+ else { -+ iconv_t pt; -+ ch++; -+ strncpy( loc_charset, ch, sizeof(loc_charset) ); -+ /* try to open iconv handle using guessed charset */ -+ if ( (pt = iconv_open( loc_charset, loc_charset )) == (iconv_t)(-1) ) -+ { -+ strcpy( loc_charset, DEFAULT_CHARSET ); -+ } else { -+ iconv_close(pt); -+ }; -+ -+ } -+ -+ return loc_charset; -+} -+ -+char *StrToUtf8( const char *inbuf ) -+{ -+ size_t length = strlen( inbuf ); -+ size_t outmaxlength = UTF8_BUF_LENGTH; -+ char *outbuf = utf8_buf; -+ char *outbuf_save = outbuf; -+ int ret; -+ -+ iconv_t handle = iconv_open( "utf-8", guess_current_locale_charset() ); -+ if(((int) handle) != -1) { -+ ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength ); -+ -+ *outbuf = '\0'; -+ iconv_close( handle ); -+ return outbuf_save; -+ } else { -+ return (char *)inbuf; -+ }; -+} -+ -+std::string StrToUtf8( const std::string &instr ) -+{ -+ size_t length = instr.length(); -+ size_t outmaxlength = UTF8_BUF_LENGTH; -+ const char *inbuf = instr.c_str(); -+ char *outbuf = utf8_buf; -+ char *outbuf_save = outbuf; -+ int ret; -+ -+ iconv_t handle = iconv_open( "utf-8", guess_current_locale_charset() ); -+ if(((int) handle) != -1) { -+ ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength ); -+ -+ *outbuf = '\0'; -+ iconv_close( handle ); -+ -+ std::string return_me = outbuf_save; -+ return return_me; -+ } else { -+ return instr; -+ }; -+} -+ -+char *Utf8ToStr( const char *inbuf ) -+{ -+ size_t length = strlen( inbuf ); -+ size_t outmaxlength = UTF8_BUF_LENGTH / 4; -+ char *outbuf = utf8_buf; -+ char *outbuf_save = outbuf; -+ int ret; -+ -+ iconv_t handle = iconv_open( guess_current_locale_charset(), "utf-8" ); -+ if(((int) handle) != -1) { -+ ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength ); -+ *outbuf = '\0'; -+ iconv_close( handle ); -+ return outbuf_save; -+ } else { -+ return (char *)inbuf; -+ }; -+} -+ -+std::string Utf8ToStr( const std::string &instr ) -+{ -+ size_t length = instr.length(); -+ const char *inbuf = instr.c_str(); -+ size_t outmaxlength = UTF8_BUF_LENGTH / 4; -+ char *outbuf = utf8_buf; -+ char *outbuf_save = outbuf; -+ int ret; -+ -+ iconv_t handle = iconv_open( guess_current_locale_charset(), "utf-8" ); -+ -+ if(((int) handle) != -1) { -+ ret = safe_iconv( handle, (const char **) &inbuf, &length, &outbuf, &outmaxlength ); -+ *outbuf = '\0'; -+ iconv_close( handle ); -+ std::string return_me = outbuf_save; -+ return return_me; -+ } else { -+ return instr; -+ }; -+} -+#endif /* HAVE_ICONV_H */ - - #endif diff -ruN /usr/ports/net/centericq/files/patch-utf8conv.h /home/AlanSung/centericq/files/patch-utf8conv.h --- /usr/ports/net/centericq/files/patch-utf8conv.h Thu Nov 28 08:37:06 2002 +++ /home/AlanSung/centericq/files/patch-utf8conv.h Thu Jan 1 08:00:00 1970 @@ -1,61 +0,0 @@ ---- src/hooks/utf8conv.h Thu Jan 1 08:00:00 1970 -+++ src/hooks/utf8conv.h Tue Nov 26 16:10:40 2002 -@@ -0,0 +1,58 @@ -+/*-------------------------------------------------------*/ -+/* utf8conv.h ( Utf8 Converter ) */ -+/*-------------------------------------------------------*/ -+/* target : Converting Utf8 from/to string/char */ -+/* modifier : clsung@dragon2.net */ -+/* create : unknown */ -+/* update : 02/11/26 */ -+/*-------------------------------------------------------*/ -+#ifndef _UTF8CONV_ -+#define _UTF8CONV_ -+ -+#ifndef HAVE_ICONV_H -+#define HAVE_ICONV_H -+#endif -+ -+#ifdef HAVE_ICONV_H -+#include -+#endif -+#include -+#define DEFAULT_CHARSET "ISO-8859-1" -+#define UTF8_BUF_LENGTH 2048 -+/* charset name cache buffer */ -+static char loc_charset[32]; -+static char utf8_buf[UTF8_BUF_LENGTH]; // max 401 length or per message -+/* -+** Name: safe_iconv -+** Purpose: 'Fault-tolerant' version if iconv. Replaces invalid seq with '?' -+** Input: see iconv manpage -+*/ -+int safe_iconv( iconv_t handle, const char **inbuf, size_t *inbytesleft, -+ char **outbuf, size_t *outbytesleft); -+ -+/* -+** Name: guess_current_locale_charset -+** Purpose: Try to guess default charset for the current locale -+** Output: charset name -+** FIXME: is there more right method for guessing charset -+ than scanning $LANG ? -+*/ -+const char* guess_current_locale_charset(); -+ -+/* -+** Name: Str2Utf8 -+** Purpose: convert a string in UTF-8 format -+** Input: inbuf - the string to convert -+** Output: a new string in UTF-8 format -+*/ -+char *StrToUtf8( const char *inbuf ); -+std::string StrToUtf8( const std::string &instr ); -+/* -+** Name: Utf8ToStr -+** Purpose: revert UTF-8 string conversion -+** Input: inbuf - the string to decode -+** Output: a new decoded string -+*/ -+char *Utf8ToStr( const char *inbuf ); -+std::string Utf8ToStr( const std::string &instr ); -+#endif diff -ruN /usr/ports/net/centericq/files/patch-yahoohook.cc /home/AlanSung/centericq/files/patch-yahoohook.cc --- /usr/ports/net/centericq/files/patch-yahoohook.cc Thu Jan 1 08:00:00 1970 +++ /home/AlanSung/centericq/files/patch-yahoohook.cc Wed Oct 8 17:44:59 2003 @@ -0,0 +1,11 @@ +--- src/hooks/yahoohook.cc.orig Fri Oct 3 03:55:06 2003 ++++ src/hooks/yahoohook.cc Wed Oct 8 17:29:21 2003 +@@ -556,7 +556,7 @@ + + string yahoohook::decode(const string &text, bool utf) { + if(utf) +- return siconv(text, "utf8", ++ return siconv(text, "utf-8", + conf.getrussian(proto) ? "koi8-u" : conf.getdefcharset()); + + return rushtmlconv("wk", text); >Release-Note: >Audit-Trail: >Unformatted: