ports/57734: [patch] cicq utf8 chars display problem.
Cheng-Lung Sung
clsung at dragon2.net
Wed Oct 8 10:10:13 UTC 2003
>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 at 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 at 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 <iconv.h>
-+#endif
-+#include <string>
-+#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:
More information about the freebsd-ports-bugs
mailing list