Hello,
  first of all, I'm sorry that I do not fill up a bug report, but I really
hate to register everywhere, if I just want to give a feedback to some
project with a bug report. I apologize for that. If you want, please
simply ignore my mail.

ICQ 6 does like to send messages directly in UTF-16 encoding in server
to client direction. It is interesting, because I have to send messages
in CP1250 encoding, but receive them in UTF-16 encoding in case that
there is a non-ascii character, otherwise already understood rtf format
is sent. It has to be something standard, because
libicq2000/src/TLV.h has defined
  const unsigned short MESSAGETEXT_FLAG1_UCS2      = 0x02
and really, when in libicq2000/src/SNAC-MSG.cpp in MessageSNAC::ParseBody
function and around nst->setMessage( t->getMessage() ) call, the encoding
can be distinguished by (t->getFlag1() == MESSAGETEXT_FLAG1_UCS2) condition.

Here are two fast-fix patches without reading "fromcharset" from icqconf
(it is very hard for me to do it from libicq2000), which I had to create
for correct Czech communication between ICQ 6 and centerim-20071003 (siconv
has a problem, that it does not work correctly with strings containing
null characters, which is with UTF-16 very common :

--- libicq2000/src/SNAC-MSG.cpp.orig    2007-11-14 14:25:24.000000000 +0100
+++ libicq2000/src/SNAC-MSG.cpp 2007-11-14 15:32:12.000000000 +0100
@@ -29,6 +29,8 @@
 using std::string;
 using std::ostringstream;
 
+string siconv(const string &atext, const string &fromcs, const string &tocs);
+
 namespace ICQ2000 {
 
   // --------------- Message (Family 0x0004) SNACs -----------------
@@ -284,7 +286,8 @@
       // coerce this into the NormalICQSubType
       NormalICQSubType *nst = new NormalICQSubType(false);
       nst->setAdvanced(false);
-      nst->setMessage( t->getMessage() );
+
+      nst->setMessage( (t->getFlag1() == MESSAGETEXT_FLAG1_UCS2) ? 
siconv(t->getMessage(), "utf-16", "cp1250") : t->getMessage() );
       m_icqsubtype = nst;
 
     } else if (channel == 0x0002) {

--- kkstrtext/kkstrtext.cc.orig 2007-11-14 15:23:40.000000000 +0100
+++ kkstrtext/kkstrtext.cc      2007-11-14 15:29:16.000000000 +0100
@@ -898,8 +898,9 @@
        iconv(cd,NULL,NULL,NULL,NULL);
 
        while(!text.empty()) {
-           sinbuf = inbuf = strdup(text.c_str());
-           inleft = strlen(inbuf);
+           inleft = text.length();
+           sinbuf = inbuf = new char[inleft];
+           memcpy(sinbuf, text.c_str(), inleft);
 
            soutleft = outleft = inleft*4;
            soutbuf = outbuf = new char[outleft];
@@ -912,7 +913,7 @@
            text.erase(0, text.size()-inleft);
 
            delete[] soutbuf;
-           free(sinbuf);
+           delete[] sinbuf;
 
            if(res == -1 && errno != EILSEQ)
                break;

-- 
Rudolf Cejka <cejkar at fit.vutbr.cz> http://www.fit.vutbr.cz/~cejkar
Brno University of Technology, Faculty of Information Technology
Bozetechova 2, 612 66  Brno, Czech Republic

-- 
_______________________________________________
Centerim-devel mailing list
[email protected]
http://centerim.org/mailman/listinfo/centerim-devel
http://www.centerim.org/

Reply via email to