diff -urN kdenetwork-2.2.orig/ksirc/KSPrefs/general.cpp kdenetwork-2.2/ksirc/KSPrefs/general.cpp
--- kdenetwork-2.2.orig/ksirc/KSPrefs/general.cpp	Thu Aug 16 19:28:08 2001
+++ kdenetwork-2.2/ksirc/KSPrefs/general.cpp	Thu Aug 16 19:37:06 2001
@@ -48,6 +48,9 @@
   if (kSircConfig->DisplayMode == 1)
       CB_MDIMode->setChecked(true);
 
+  CB_UseISO2022JP->setChecked(kConfig->readBoolEntry("UseISO2022JP", true));
+  kSircConfig->UseISO2022JP = kConfig->readBoolEntry("UseISO2022JP", true);
+
   CB_DisplayTopic->setChecked(kSircConfig->DisplayTopic);
 
   KIL_WindowLength->setValue(kSircConfig->WindowLength);
@@ -93,6 +96,7 @@
   kSircConfig->NickCompletion = CB_NickCompletion->isChecked();
   kSircConfig->ColourPicker = CB_ColourPicker->isChecked();
   kSircConfig->AutoRejoin = CB_AutoRejoin->isChecked();
+  kSircConfig->UseISO2022JP = CB_UseISO2022JP->isChecked();
   kSircConfig->BackgroundPix = CB_BackgroundPix->isChecked();
   kSircConfig->transparent = CB_BackgroundPix->isChecked();
   kSircConfig->BackgroundFile = SLE_BackgroundFile->text();
@@ -114,6 +118,7 @@
   kConfig->writeEntry("NickCompletion", kSircConfig->NickCompletion);
   kConfig->writeEntry("ColourPicker", kSircConfig->ColourPicker);
   kConfig->writeEntry("AutoRejoin", kSircConfig->AutoRejoin);
+  kConfig->writeEntry("UseISO2022JP", kSircConfig->UseISO2022JP);
   kConfig->writeEntry("BackgroundPix", kSircConfig->BackgroundPix);
   kConfig->writeEntry("transparent", kSircConfig->transparent);
   kConfig->writeEntry("BackgroundFile", kSircConfig->BackgroundFile);
diff -urN kdenetwork-2.2.orig/ksirc/KSPrefs/generalData.cpp kdenetwork-2.2/ksirc/KSPrefs/generalData.cpp
--- kdenetwork-2.2.orig/ksirc/KSPrefs/generalData.cpp	Thu Aug 16 19:28:08 2001
+++ kdenetwork-2.2/ksirc/KSPrefs/generalData.cpp	Thu Aug 16 19:37:06 2001
@@ -75,6 +75,12 @@
         CB_AutoRejoin->setChecked( TRUE );
         gl->addWidget(CB_AutoRejoin, 2, 3);
 
+	CB_UseISO2022JP = new
+	  QCheckBox( i18n( "Use ISO-2022-JP Codec" ), bg, "CheckBox_7");
+        CB_UseISO2022JP->setAutoRepeat( FALSE );
+        CB_UseISO2022JP->setChecked( TRUE );
+        gl->addWidget(CB_UseISO2022JP, 3, 3);
+
         CB_TimeStamp = new
           QCheckBox( i18n( "Time Stamp" ), bg, "CheckBox_TimeStamp" );
         CB_TimeStamp->setAutoRepeat( FALSE );
diff -urN kdenetwork-2.2.orig/ksirc/KSPrefs/generalData.h kdenetwork-2.2/ksirc/KSPrefs/generalData.h
--- kdenetwork-2.2.orig/ksirc/KSPrefs/generalData.h	Thu Aug 16 19:28:08 2001
+++ kdenetwork-2.2/ksirc/KSPrefs/generalData.h	Thu Aug 16 19:37:06 2001
@@ -46,6 +46,7 @@
     QCheckBox* CB_NickCompletion;
     QCheckBox* CB_ColourPicker;
     QCheckBox* CB_AutoRejoin;
+    QCheckBox* CB_UseISO2022JP;
     QCheckBox* CB_BackgroundPix;
     QCheckBox* CB_MDIMode;
     QLineEdit* SLE_BackgroundFile;
diff -urN kdenetwork-2.2.orig/ksirc/KSircListBox/irclistitem.cpp kdenetwork-2.2/ksirc/KSircListBox/irclistitem.cpp
--- kdenetwork-2.2.orig/ksirc/KSircListBox/irclistitem.cpp	Thu Aug 16 19:28:08 2001
+++ kdenetwork-2.2/ksirc/KSircListBox/irclistitem.cpp	Thu Aug 16 19:37:06 2001
@@ -11,6 +11,8 @@
 
 #include <kdebug.h>
 
+#include <qtextcodec.h>
+
 #include "config.h"
 
 QIntCache<QPixmap> *ircListItem::PaintCache = 0x0;
@@ -156,6 +158,9 @@
   // Copy permenant contents into temp string so we can mangle it, but always get the orignal back
   itext = rtext;
 
+//QTextCodec *codec = QTextCodec::codecForName("ISO-2022-JP");
+//cout << "setupPainterText: rtext = [" << codec->fromUnicode(rtext) << "]\n";
+//cout << "setupPainterText: itext = [" << codec->fromUnicode(itext) << "]\n";
 
   // Insert selection markers if turned on
 
@@ -224,20 +229,25 @@
                 (itext[newi] != '\\'); newi--);
           if(newi > lastp)
             i = newi+1;
-          paint_text->append(itext.mid(lastp, i-lastp));
+//cout << "setupPainterText: itext = [" << itext << "]\n";
+          paint_text->append(itext.mid(lastp, i-lastp).utf8());
+//          paint_text->append(itext.mid(lastp, i-lastp));
           ig = 0;
           width = xPos;
           lastp = i;
         }
       }
     }
-    paint_text->append(itext.mid(lastp, i-lastp));
+    paint_text->append(itext.mid(lastp, i-lastp).utf8());
+//    paint_text->append(itext.mid(lastp, i-lastp));
     rows = paint_text->count();
   }
   else{
     rows = 1;
     //    linewidth = fm.width(itext);
-    paint_text->append(itext);
+//cout << "setupPainterText: else: itext = [" << codec->fromUnicode(itext) << "]\n";
+    paint_text->append(itext.utf8());
+//    paint_text->append(itext);
   }
 
   linewidth = parent_lb->viewport()->width() - 35; // set out width to the parent width.
@@ -285,6 +295,8 @@
     char *txt;
     int row = 0;
     for(txt = paint_text->first(); txt != 0; txt = paint_text->next(), row++){
+//cout << "setupPainterText: before colourDrawText(): txt = [" << codec->fromUnicode(txt) << "]\n";
+//cout << "setupPainterText: before colourDrawText(): txt = [" << txt << "]\n";
       KSPainter::colourDrawText(&p, xPos,yPos+lineheight*row, txt);
     }
     p.end();
diff -urN kdenetwork-2.2.orig/ksirc/KSircListBox/kspainter.cpp kdenetwork-2.2/ksirc/KSircListBox/kspainter.cpp
--- kdenetwork-2.2.orig/ksirc/KSircListBox/kspainter.cpp	Thu Aug 16 19:28:08 2001
+++ kdenetwork-2.2/ksirc/KSircListBox/kspainter.cpp	Thu Aug 16 19:37:06 2001
@@ -3,6 +3,8 @@
 #include <stdlib.h>
 #include <iostream.h>
 
+#include <qtextcodec.h>
+
 #include <qregexp.h>
 #include <qapplication.h>
 #include <knotifyclient.h>
@@ -40,6 +42,24 @@
   return -1;
 }
 
+static int i18nDrawText(QPainter *p, int startx, int starty, QCString &str)
+{
+  static QTextCodec *codec = QTextCodec::codecForName("ISO-2022-JP");
+//cout << "i18nDrawText: str = [" << QString::fromUtf8(str) << "]\n";
+//cout << "i18nDrawText: str.length() = [" << str.length() << "]\n";
+//cout << "i18nDrawText: fromUnicode(str) = [" << codec->fromUnicode(QString::fromUtf8(str)) << "]\n";
+  if (kSircConfig->UseISO2022JP) {
+//cout << "i18nDrawText: UseISO2022JP is true.\n";
+    p->drawText(startx, starty, QString::fromUtf8(str));
+  } else {
+//cout << "i18nDrawText: UseISO2022JP is false.\n";
+    p->drawText(startx, starty, QString::fromLocal8Bit(str));
+  }
+  startx += p->fontMetrics().width(str);
+  str = "";
+  return startx;
+}
+
 void KSPainter::colourDrawText(QPainter *p, int startx, int starty,
 				 const char *str, int length)
 {
@@ -49,13 +69,17 @@
   int loc = 0, i;
   buf[2] = 0;
 
+//static QTextCodec *codec = QTextCodec::codecForName("ISO-2022-JP");
+//cout << "colourDrawText: first: fromUnicode(str) = [" << codec->fromUnicode(str) << "]\n";
   PainterState curState(p);
+  QCString pstr = "";
 
   for(loc = 0; (str[loc] != 0x00) && (loc != length) ; loc++){
     if(str[loc] == 0x03 || str[loc] == '~'){
       i = loc;
-      p->drawText(startx, starty, str + offset, i-offset);
-      startx += p->fontMetrics().width(str + offset, i-offset);
+      // p->drawText(startx, starty, str + offset, i-offset);
+      // startx += p->fontMetrics().width(str + offset, i-offset);
+      pstr += QCString(str + offset, i-offset+1);
       offset = i;
       //      lastp = i;
       if((str[i+1] >= 0x30) && (str[i+1] <= 0x39)){
@@ -71,9 +95,11 @@
 	}
 	
 	pcolour = atoi(buf);
-        if(pcolour < maxcolour)
+        if(pcolour < maxcolour) {
+//cout << "colourDrawText: pcolour < maxcolour: fromUnicode(pstr) = [" << codec->fromUnicode(pstr) << "]\n";
+          startx = i18nDrawText(p, startx, starty, pstr);
           curState.setFGCol(num2colour[pcolour]);
-	else
+	} else
           i = loc;
 
 	if(str[i] == ','){
@@ -95,8 +121,11 @@
 	      else
 		bcolour -= 1;
 	    }
-            if(bcolour < maxcolour )
+            if(bcolour < maxcolour ) {
+//cout << "colourDrawText: bcolour < maxcolour: fromUnicode(pstr) = [" << codec->fromUnicode(pstr) << "]\n";
+	      startx = i18nDrawText(p, startx, starty, pstr);
               curState.setBGCol(num2colour[bcolour]);
+	    }
 
 	  }
 	}
@@ -143,7 +172,9 @@
       offset += i - loc;
     }
   }
-  p->drawText(startx, starty, str + offset, loc-offset);
+  pstr += QCString(str + offset, loc-offset+1);
+//cout << "colourDrawText: last: fromUnicode(pstr) = [" << codec->fromUnicode(pstr) << "]\n";
+  startx = i18nDrawText(p, startx, starty, pstr);
 
 }
 
diff -urN kdenetwork-2.2.orig/ksirc/ahistlineedit.cpp kdenetwork-2.2/ksirc/ahistlineedit.cpp
--- kdenetwork-2.2.orig/ksirc/ahistlineedit.cpp	Thu Aug 16 19:28:08 2001
+++ kdenetwork-2.2/ksirc/ahistlineedit.cpp	Thu Aug 16 19:37:06 2001
@@ -112,26 +112,26 @@
     case Key_Up:
       if(hist.at() == current){ // same as Key_Down
 	hist.remove(current);
-	hist.insert(current, text());
+	hist.insert(current, text().utf8());
       }
       if(hist.at() < 1){ // Same idea as Key_Down so look there for an
 	hist.last();     // explanation
-	setText(hist.current());
+	setText(QString::fromUtf8(hist.current()));
       }
       else
-	setText(hist.prev()); // Set text to prev item
+	setText(QString::fromUtf8(hist.prev())); // Set text to prev item
       break;
     case Key_Down:
       if(hist.at() == current){ // If we're leaving the active line, save it
 	hist.remove(current);   // remove last line
-	hist.insert(current, text()); // update it to the current line
+	hist.insert(current, text().utf8()); // update it to the current line
       }
       if(hist.at() >= (int) hist.count()-1){ // If we're moving byond the end
 	hist.first();                        // roll to first one
-	setText(hist.current());             // set text to first line
+	setText(QString::fromUtf8(hist.current()));             // set text to first line
       }
       else
-	setText(hist.next());                // Set text to the next one
+	setText(QString::fromUtf8(hist.next()));                // Set text to the next one
       break;
     case Key_Return:
     case Key_Enter:
@@ -141,7 +141,7 @@
       }
       if(text() != ""){
 	hist.remove(current); // remove the "dummy" entry
-	hist.append(text()); // add the current text to the end
+	hist.append(text().utf8()); // add the current text to the end
 	hist.append(""); // set the next line to blank
 	current = hist.count() - 1; // move ahead one.
       }
diff -urN kdenetwork-2.2.orig/ksirc/baserules.cpp kdenetwork-2.2/ksirc/baserules.cpp
--- kdenetwork-2.2.orig/ksirc/baserules.cpp	Thu Aug 16 19:28:08 2001
+++ kdenetwork-2.2/ksirc/baserules.cpp	Thu Aug 16 19:37:06 2001
@@ -20,6 +20,7 @@
   filterRule *fr;
   filterRuleList *frl = new filterRuleList();
   frl->setAutoDelete(TRUE);
+/*
   if(kSircConfig->filterKColour == TRUE){
     // 3 stage rule to filter:
     // ~blah~<something> stuff with ~ here and ~ there
@@ -58,6 +59,7 @@
     fr->to = "~~$1";
     frl->append(fr);
   }
+*/
   if(kSircConfig->filterMColour == TRUE){
     fr = new filterRule();
     fr->desc = "Remove mirc Colours";
diff -urN kdenetwork-2.2.orig/ksirc/chanparser.cpp kdenetwork-2.2/ksirc/chanparser.cpp
--- kdenetwork-2.2.orig/ksirc/chanparser.cpp	Thu Aug 16 19:28:08 2001
+++ kdenetwork-2.2/ksirc/chanparser.cpp	Thu Aug 16 19:37:06 2001
@@ -9,9 +9,11 @@
 #include <ssfeprompt.h>
 #include <string.h>
 #include <kdebug.h>
+#include <qtextcodec.h>
 #include "config.h"
 #include "KSTicker/ksticker.h"
 
+
 // Static parser table is "initialized"
 QDict<parseFunc> ChannelParser::parserTable;
 
@@ -59,6 +61,9 @@
 {
    // for older Qts
 
+// QTextCodec *codec=QTextCodec::codecForName("ISO-2022-JP");
+// cout << "parse: string = [" << codec->fromUnicode(string) << "]\n";
+
   parseFunc *pf;
   if(string.length() < 3){
     return new parseError(string, QString("Dumb string, too short"));
@@ -93,6 +98,7 @@
   }
   // Pre-parsing is now complete
 
+//cout << "parse: string.mid(0,3) = [" << codec->fromUnicode(string.mid(0,3)) << "]\n";
   pf = parserTable[string.mid(0, 3)];
   if(pf != 0x0){
     parseResult *result = (this->*(pf->parser))(string);
@@ -108,9 +114,11 @@
   // Little bit of past parsing to catch one we've missed
   if((string[0] == '*') && (string[2] == '*')) {
     string.remove(0, 3);
+// cout << "parse: string = [" << codec->fromUnicode(string) << "]\n";
     return new parseSucc(string, kSircConfig->colour_info, top->pix_bball);
   }
   // If it's unkown we just fall out of the function
+// cout << "parse: fall out ...\n";
   return 0;
 }
 
@@ -125,17 +133,28 @@
 parseResult * ChannelParser::parseSSFEStatus(QString string)
 {
 
+  QTextCodec *codec=QTextCodec::codecForName("ISO-2022-JP");
+
   string.remove(0, 4); // strip off the first 4 characters
-  const char *status;
+//  const char *status;
+  
   if(string.length() < 8)
     return new parseError("", "Unable to parse status string");
 
-  status = string.ascii()+8;
+  QString status = string.right(string.length()-8).utf8();
+cout << "parseSSFEStatus: codec->fromUnicode(QString::fromUtf8(string)) = [" << codec->fromUnicode(QString::fromUtf8(string)) << "]\n";
+cout << "parseSSFEStatus: codec->fromUnicode(QString::fromUtf8(status)) = [" << codec->fromUnicode(QString::fromUtf8(status)) << "]\n";
   char nick[101], modes[101], chan[101], chanmode[101];
   int away = 0;
   modes[0] = 0x0; modes[1] = 0x0; // No mode set for user
   int found = sscanf(status, "%100s (%100[^)]) on %100s (%100[^)])", nick, modes, chan, chanmode); // Channel modes and user modes
-  if(found != 4){
+cout << "parseSSFEStatus: found = [" << found << "]\n";
+cout << "parseSSFEStatus: nick = [" << nick << "]\n";
+cout << "parseSSFEStatus: modes = [" << modes << "]\n";
+cout << "parseSSFEStatus: codec->fromUnicode(QString::fromUtf8(chan)) = [" << codec->fromUnicode(QString::fromUtf8(chan)) << "]\n";
+//cout << "parseSSFEStatus: chanmode = [" << chanmode << "]\n";
+//  if(found != 4){
+  if(found < 3){
     found = sscanf(status, "%100s on %100s (%100[^)])", nick, chan, chanmode); // No user mode set
     away = 0;
     if(found != 3){
@@ -166,6 +185,7 @@
       }
     }
   }
+
   if(away){
     if(strlen(chan) < 98){
       memmove(chan+2, chan, 98);
@@ -174,7 +194,7 @@
     }
   }
 
-  QString status_line = chan;
+  QString status_line = QString::fromUtf8(QString(chan));
   status_line += QString(" (") + chanmode + ") " +  nick +  " (" + modes + ") ";
 
   /*
@@ -189,6 +209,8 @@
     }
   }
 
+cout << "parseSSFEStatus: codec->fromUnicode(top->topic) = [" << codec->fromUnicode(top->topic) << "]\n";
+cout << "parseSSFEStatus: top->topic.length() = [" << top->topic.length() << "]\n";
   if(kSircConfig->DisplayTopic){
     if(top->topic.length() > 0)
       status_line += "T: " + top->topic;
@@ -196,7 +218,10 @@
       status_line += "T: " + QString("<No Topic Set>");
   }
 
-  if(strcmp(top->caption, status_line) != 0){
+//cout << "parseSSFEStatus: codec->fromUnicode(top->caption) = [" << codec->fromUnicode(top->caption) << "]\n";
+//cout << "parseSSFEStatus: codec->fromUnicode(status_line) = [" << codec->fromUnicode(status_line) << "]\n";
+  if(top->caption != status_line){
+//cout << "parseSSFEStatus: not matched\n";
     if(nick[0] == '@')                 // If we're an op,,
       // update the nicks popup menu
       top->opami = TRUE;                  // opami = true sets us to an op
@@ -212,6 +237,8 @@
     top->caption = status_line;           // Make copy so we're not
     // constantly changing the title bar
   }
+else
+cout << "parseSSFEStatus: matched\n";
   return new parseSucc(QString::null); // Null string, don't display anything
 }
 
@@ -301,7 +328,6 @@
 
 parseResult * ChannelParser::parseSSFEReconnect(QString)
 {
-
   if(top->channel_name[0] == '#'){
     QString str = "/join " + QString(top->channel_name) + "\n";
     emit top->outputLine(str);
@@ -330,6 +356,9 @@
   char *nick;
   char *place_holder;
 
+//QTextCodec *codec = QTextCodec::codecForName("ISO-2022-JP");
+//cout << "parseINFONicks: codec->fromUnicode(in_string) = [" << codec->fromUnicode(in_string) << "]\n";
+
   int count;
   char channel_name[101];
 
@@ -352,21 +381,31 @@
     return new parseSucc(QString::null);           // Parsing ok, don't print anything though
   }
 
+//cout << "parseINFONicks: codec->fromUnicode(string) = [" << codec->fromUnicode(string) << "]\n";
 
   // Get the channel name portion of the string
   // Search for the first space, since : can be embeded into channel names.
-  count = sscanf(string, "*!* Users on %100[^ ]", channel_name);
+  count = sscanf(string.utf8(), "*!* Users on %100[^ ]", channel_name);
+  QString chan = QString::fromUtf8(channel_name);
+//cout << "parseINFONicks: chan = [" << codec->fromUnicode(chan) << "]\n";
   if(count < 1){
     return new parseError(string, QString("Could not find channel name"));
   }
 
   // Remove the : from the end.
-  channel_name[strlen(channel_name)-1] = 0x0;
+  chan = chan.left(chan.length()-1);
+//cout << "parseINFONicks: before if: chan.length() = [" << chan.length() << "]\n";
+//cout << "parseINFONicks: before if: chan.lower() = [" << codec->fromUnicode(chan.lower()) << "]\n";
+//cout << "parseINFONicks: before if: top->channel_name.length() = [" << codec->fromUnicode(top->channel_name).length() << "]\n";
+//cout << "parseINFONicks: before if: codec->fromUnicode(top->channel_name) = [" << codec->fromUnicode(top->channel_name) << "]\n";
+//cout << "parseINFONicks: before if: codec->fromUnicode(top->channel_name).lower() = [" << codec->fromUnicode(top->channel_name).lower() << "]\n";
 
-  if (strcasecmp(channel_name,top->channel_name) != 0){
+  if (chan.lower() != top->channel_name.lower()){
     string.remove(0,3);
+//cout << "parseINFONicks: chan & channel_name differ: codec->fromUnicode(string) = [" << codec->fromUnicode(string) << "]\n";
     return new parseSucc(string,kSircConfig->colour_info,top->pix_info);
   }
+//cout << "parseINFONicks: chan & channel_name matched: codec->fromUnicode(string) = [" << codec->fromUnicode(string) << "]\n";
 
   if(clear_box == TRUE){
     current_item = top->nicks->currentItem();
@@ -375,14 +414,17 @@
   }
 
   int start = string.find(": ", 0, FALSE); // Find start of nicks
+//cout << "parseINFONicks: start = [" << start << "]\n";
   if (start < 0)
     return new parseError(string, QString("Could not find start of nicks"));
 
   place_holder = new char[string.length()];
   strcpy(place_holder, string.ascii()+start+2);
   nick = strtok(place_holder, " ");
+//cout << "parseINFONicks: codec->fromUnicode(nick) = [" << codec->fromUnicode(nick) << "]\n";
 
   while(nick != 0x0){                     // While there's nick to go...
+//cout << "parseINFONicks: codec->fromUnicode(nick) = [" << codec->fromUnicode(nick) << "]\n";
     nickListItem *irc = new nickListItem();
 
     bool done = FALSE;
@@ -409,6 +451,7 @@
       nick++; // Move ahead to next character
     }
 
+//cout << "parseINFONicks: codec->fromUnicode(nick) = [" << codec->fromUnicode(nick) << "]\n";
     irc->setText(nick);
     top->nicks->inSort(irc);
     nick = strtok(NULL, " ");
@@ -422,16 +465,31 @@
 {
   char nick[101], channel[101];
 
+QTextCodec *codec = QTextCodec::codecForName("ISO-2022-JP");
+//cout << "parseINFOJoin: codec->fromUnicode(string) = [" << codec->fromUnicode(string) << "]\n";
+
+//cout << "parseINFOJoin: top->channel_name.length() = [" << codec->fromUnicode(top->channel_name).length() << "]\n";
+//cout << "parseINFOJoin: top->channel_name = [" << codec->fromUnicode(top->channel_name) << "]\n";
+
   string.remove(0, 4);                   // strip *>* to save a few compares
-  if(sscanf(string, "You have joined channel %100s", channel) > 0){
-    QString chan = QString(channel).lower();
+  if(sscanf(string.utf8(), "You have joined channel %100s", channel) > 0){
+//cout << "parseINFOJoin: channel = [" << QString::fromUtf8(channel) << "]\n";
+    QString chan = QString::fromUtf8(channel);
+//cout << "parseINFOJoin: chan.length() = [" << chan.length() << "]\n";
+//cout << "parseINFOJoin: chan = [" << chan << "]\n";
+//cout << "parseINFOJoin: codec->fromUnicode(chan).length() = [" << codec->fromUnicode(chan).length() << "]\n";
+//cout << "parseINFOJoin: codec->fromUnicode(chan) = [" << codec->fromUnicode(chan) << "]\n";
     if(strcasecmp(top->channel_name, chan) == 0)
+//cout << "parseINFOJoin: top->channel_name & chan mached!\n";
       top->show();
-    emit top->open_toplevel(chan);
+//cout << "parseINFOJoin: in if phase: なじょしてまたopen?\n";
+    emit top->open_toplevel(chan); // new_toplevel() expects a unicode string as its argument
+//cout << "parseINFOJoin: in if phase: string = [" << codec->fromUnicode(string) << "]\n";
     return new parseSucc(" " + string, kSircConfig->colour_chan, top->pix_greenp);
   }
   else if(sscanf(string, "%100s %*s has joined channel %100s", nick, channel) > 0){
-    if(strcasecmp(top->channel_name, channel) != 0){
+    QString chan = QString(codec->toUnicode(channel));
+    if(strcasecmp(top->channel_name, chan) != 0){
       return new parseWrongChannel(" " + string, kSircConfig->colour_error, top->pix_greenp);
     }
     //	nicks->insertItem(s3, 0);      // add the sucker
@@ -485,6 +543,9 @@
        return new parseWrongChannel(string, kSircConfig->colour_error, top->pix_madsmile);
     if (kSircConfig->AutoRejoin == TRUE)
     {
+static QTextCodec *codec = QTextCodec::codecForName("ISO-2022-JP");
+cout << "parseINFOPart: top->channel_name = [" << codec->fromUnicode(top->channel_name) << "]\n";
+cout << "parseINFOPart: top->channel_name = [" << top->channel_name << "]\n";
        QString str = "/join " + QString(top->channel_name) + "\n";
        emit top->outputLine(str);
        if(top->ticker)
@@ -500,6 +561,9 @@
       int result = KMessageBox::questionYesNo(top, string, i18n("You Have Been Kicked"), i18n("Rejoin"), i18n("Leave"));
       if (result == KMessageBox::Yes)
       {
+static QTextCodec *codec = QTextCodec::codecForName("ISO-2022-JP");
+cout << "parseINFOPart: top->channel_name = [" << codec->fromUnicode(top->channel_name) << "]\n";
+cout << "parseINFOPart: top->channel_name = [" << top->channel_name << "]\n";
         QString str = "/join " + QString(top->channel_name) + "\n";
 	emit top->outputLine(str);
 	if(top->ticker)
@@ -772,23 +836,39 @@
 parseResult * ChannelParser::parseINFOTopic(QString string)
 {
   char channel[101];
+  static QTextCodec *codec = QTextCodec::codecForName("ISO-2022-JP");
 
+cout << "parseINFOTopic: codec->fromUnicode(string) = [" << codec->fromUnicode(string) << "]\n";
   string.remove(0, 4); // Remove the leading *T* and space
   // *T* Topic for #kde: Don't use koffice! You will get into deep emotional problems!
-  int found = sscanf(string, "Topic for %100[^:]: ", channel);
+  QString str;
+  if (kSircConfig->UseISO2022JP)
+    str = string;
+  else
+    str = QString::fromLocal8Bit(string.latin1());
+
+  int found = sscanf(str.utf8(), "Topic for %100[^:]: ", channel);
+cout << "parseINFOTopic: found = [" << found << "]\n";
+  QString cname = QString::fromUtf8(channel).lower();
+cout << "parseINFOTopic: codec->fromUnicode(cname) = [" << codec->fromUnicode(cname) << "]\n";
   if(found == 1){
     // If this is the correct channel, set the status line for the topic
-    if(strcasecmp(top->channel_name, channel) == 0){
-      int start = string.find(": ")+1;
-      int end = string.length() - start;
-      top->topic = string.mid(start, end);
-      top->topic.replace(QRegExp("~~"), "~");
+cout << "parseINFOTopic: codec->fromUnicode(top->channel_name) = [" << codec->fromUnicode(top->channel_name) << "]\n";
+    if(top->channel_name == cname){
+cout << "parseINFOTopic: *** matched! ***\n";
+      int start = str.find(": ")+2;
+//      int start = str.find(": ")+1;
+      int len = str.length() - start;
+      top->topic = str.mid(start, len);
+cout << "parseINFOTopic: codec->fromUnicode(top->topic) = [" << codec->fromUnicode(top->topic) << "]\n";
     }
   }
   else {
-    found = sscanf(string, "%*s has changed the topic on channel %100s to", channel);
+    found = sscanf(str.utf8(), "%*s has changed the topic on channel %100s to", channel);
+    QString cname = QString::fromUtf8(channel);
     if(found == 1){
-      if(strcasecmp(top->channel_name, channel) == 0){
+//      if(strcasecmp(top->channel_name, channel) == 0){
+    if(top->channel_name.lower() == cname.lower()){
         int start = string.find(" \"")+2;
         int end = string.length() - start - 1; // 1 to remove trailing "
         top->topic = string.mid(start, end);
diff -urN kdenetwork-2.2.orig/ksirc/config.h kdenetwork-2.2/ksirc/config.h
--- kdenetwork-2.2.orig/ksirc/config.h	Thu Aug 16 19:28:08 2001
+++ kdenetwork-2.2/ksirc/config.h	Thu Aug 16 19:37:06 2001
@@ -20,6 +20,7 @@
   bool NickCompletion;
   bool ColourPicker;
   bool AutoRejoin;
+  bool UseISO2022JP;
   bool BackgroundPix;
   QString BackgroundFile;
   bool transparent;
diff -urN kdenetwork-2.2.orig/ksirc/dsirc kdenetwork-2.2/ksirc/dsirc
--- kdenetwork-2.2.orig/ksirc/dsirc	Thu Aug 16 19:28:08 2001
+++ kdenetwork-2.2/ksirc/dsirc	Thu Aug 16 19:37:06 2001
@@ -285,7 +285,7 @@
   for($i=0; $i<=$#channels; $i++){
     $s = " [sirc]  ";
     $t = $channels[$i];
-    $t =~ tr/A-Z/a-z/;
+#    $t =~ tr/A-Z/a-z/;
     $s.="*" if $umode =~ /o/;
     $s.="\@" if $t && $haveops{$t};
     $s.=$nick;
@@ -1629,7 +1629,7 @@
 
 sub modestripper {
   local($chnl, $what)=@_;
-  $chnl =~ tr/A-Z/a-z/;
+#  $chnl =~ tr/A-Z/a-z/;
   local($how, $modes, @args)=('+', split(/ +/, $what));
   foreach $m (split(//, $modes)) {
     if ($m =~ /[\-\+]/) {
@@ -1881,7 +1881,7 @@
     local($g, $c, $m)=split(/ +/, $args, 3);
     $m =~ s/^://;
     $m =~ s/ $//;
-    $c =~ tr/A-Z/a-z/;
+#    $c =~ tr/A-Z/a-z/;
     if (grep(&eq($_, $c), @channels)) {
       if (defined($mode{$c})) {
 	&tell("*\cb+\cb* Mode for channel $c is \"$m\"");
@@ -1935,7 +1935,7 @@
     else {               # KSIRC MOD
       &tell("~${c}~*\cb#\cb* Users on $c: $r"); # KSIRC MOD
     }                                           # KSIRC MOD
-    $c =~ tr/A-Z/a-z/;
+#    $c =~ tr/A-Z/a-z/;
     $haveops{$c}=1 if ($r =~ /\@${n}( |$)/i);
     &dostatus if &eq($c, $talkchannel);
   } elsif ($cmd eq '366'){                      # KSIRC MOD
@@ -2182,7 +2182,7 @@
 	} else {
 	  $talkchannel='';
 	}
-	$channel =~ tr/A-Z/a-z/;
+#	$channel =~ tr/A-Z/a-z/;
 	&dohooks("kick", $newarg, $channel, $args);
 	delete $mode{$channel};
 	delete $limit{$channel};
diff -urN kdenetwork-2.2.orig/ksirc/ioLAG.cpp kdenetwork-2.2/ksirc/ioLAG.cpp
--- kdenetwork-2.2.orig/ksirc/ioLAG.cpp	Thu Aug 16 19:28:08 2001
+++ kdenetwork-2.2/ksirc/ioLAG.cpp	Thu Aug 16 19:37:06 2001
@@ -13,6 +13,7 @@
 #include "config.h"
 
 #include <kdebug.h>
+#include <qtextcodec.h>
 
 KSircIOLAG::KSircIOLAG(KSircProcess *_proc)
   : QObject(),
@@ -33,16 +34,18 @@
 
 void KSircIOLAG::sirc_receive(QString str, bool)
 {
+  static QTextCodec *codec = QTextCodec::codecForLocale();
+  QString str2 = codec->toUnicode(str);
 
   if(str.contains("*L*")){
     int s1, s2;
-    s1 = str.find("*L* ") + 4;
-    s2 = str.length();
+    s1 = str2.find("*L* ") + 4;
+    s2 = str2.length();
     if(s1 < 0 || s2 < 0){
-      kdDebug() << "Lag mesage broken: " << str << endl;
+      kdDebug() << "Lag mesage broken: " << str << endl; // do not change str in this line to str2.
       return;
     }
-    QString lag = str.mid(s1, s2 - s1);
+    QString lag = str2.mid(s1, s2 - s1);
     //    cerr << "Lag: " << str << endl;
     //    cerr << "Setting lag to: " << lag << endl;
     (proc->getWindowList())["!all"]->control_message(SET_LAG, lag);
diff -urN kdenetwork-2.2.orig/ksirc/iocontroller.cpp kdenetwork-2.2/ksirc/iocontroller.cpp
--- kdenetwork-2.2.orig/ksirc/iocontroller.cpp	Thu Aug 16 19:28:08 2001
+++ kdenetwork-2.2/ksirc/iocontroller.cpp	Thu Aug 16 19:37:06 2001
@@ -75,6 +75,8 @@
 #include <kstddirs.h>
 #include <kdebug.h>
 
+#include <qtextcodec.h>
+
 extern KApplication *kApp;
 extern global_config *kSircConfig;
 
@@ -151,10 +153,14 @@
 
    */
 
+//cout << "---------------\n Entering stdout_read\n ---------------\n";
   int pos,pos2,pos3;
   QString name, line;
 
-  QString buffer(QString::fromLocal8Bit(_buffer, buflen));
+//  QString buffer(QString::fromLocal8Bit(_buffer, buflen));
+  QString buffer(QString::fromLatin1(_buffer, buflen));
+cout << "stdout_read: _buffer = [" << _buffer << "]\n";
+cout << "stdout_read: buffer = [" << buffer << "]\n";
   //  kdDebug() << "<-- read: " << buffer;
   name = "!default";
 
@@ -172,23 +178,39 @@
     }
   }
 
+  static QTextCodec *codec = QTextCodec::codecForName("ISO-2022-JP");
+  QString str;
+  if (kSircConfig->UseISO2022JP)
+    str = codec->toUnicode(buffer);
+  else
+    str = QString::fromLocal8Bit(buffer.latin1());
+
+cout << "stdout_read: str = [" << str << "]\n";
+
   pos = pos2 = 0;
   ksircproc->TopList["!all"]->control_message(STOP_UPDATES, "");
   do{
-    pos2 = buffer.find('\n', pos);
+    pos2 = str.find('\n', pos);
 
     if(pos2 == -1)
-      pos2 = buffer.length();
+      pos2 = str.length();
 
-    line = buffer.mid(pos, pos2 - pos);
-    if((line.length() > 0) && (line[0] == '~')){
+    line = str.mid(pos, pos2 - pos);
+cout << "iocoltroller.cpp: stdout_read: 1: line = [" << codec->fromUnicode(line) << "]" << "\n";
+    if((line.length() > 0) && (line[0] == '~')) {
       pos3 = line.find('~', 1);
       if(pos3 > 0){
-	name = line.mid(1,pos3-1);
+	name = line.mid(1, pos3-1);
 	name = name.lower();
+cout << "iocoltroller.cpp: stdout_read: 2: codec->fromUnicode(name) = [" << codec->fromUnicode(name) << "]" << "\n";
 	line.remove(0, pos3+1);
       }
     }
+cout << "iocoltroller.cpp: stdout_read: 3: line = [" << codec->fromUnicode(line) << "]" << "\n";
+
+    // qDebug("\tname = '%s'", (const char *) name.local8Bit());
+    // qDebug("\tline = '%s'", (const char *) line.latin1());
+cout << "iocoltroller.cpp: stdout_read: 4: codec->fromUnicode(name) = [" << codec->fromUnicode(name) << "]" << "\n";
     if(!(ksircproc->TopList)[name]){
       // Ignore ssfe control messages with `
       // we left channel, don't open a window for a control message
@@ -208,7 +230,7 @@
 //    debug("After: %s", line.data());
 
     pos = pos2+1;
-  } while((uint) pos < buffer.length());
+  } while((uint) pos < str.length());
 
   ksircproc->TopList["!all"]->control_message(RESUME_UPDATES, "");
 
@@ -224,14 +246,17 @@
 }
 
 void KSircIOController::stdin_write(QString s)
+// s is expected to be a unicode string.
 {
+  static QTextCodec *codec = QTextCodec::codecForName("ISO-2022-JP");
   if (!proc->isRunning())
   {
      kdDebug() << "writing to a dead process! (" << s << ")\n";
      return;
   }
     // kdDebug() << "--> wrote: " << s;
-  buffer += s;
+
+  buffer += codec->fromUnicode(s);
   if(proc_CTS == TRUE){
     int len = buffer.length();
     if(send_buf != 0x0){
@@ -253,7 +278,6 @@
     kdDebug() << "IOController: KProcess barfing again!\n";
   }
   //  write(sirc_stdin, s, s.length());
-
 }
 
 void KSircIOController::sircDied(KProcess *)
diff -urN kdenetwork-2.2.orig/ksirc/ksirc.cpp kdenetwork-2.2/ksirc/ksirc.cpp
--- kdenetwork-2.2.orig/ksirc/ksirc.cpp	Thu Aug 16 19:28:08 2001
+++ kdenetwork-2.2/ksirc/ksirc.cpp	Thu Aug 16 19:37:06 2001
@@ -120,6 +120,8 @@
   kSircConfig->timestamp = kConfig->readBoolEntry("TimeStamp", false);
   kConfig->setGroup( "StartUp" );
   kSircConfig->nickName = kConfig->readEntry( "Nick" );
+  kSircConfig->UseISO2022JP = kConfig->readBoolEntry("UseISO2022JP", true);
+cout << "UseISO2022JP = [" << kSircConfig->UseISO2022JP << "]\n";
 
 #if 0
   kConfig->setGroup("ReleaseNotes");
diff -urN kdenetwork-2.2.orig/ksirc/ksircprocess.cpp kdenetwork-2.2/ksirc/ksircprocess.cpp
--- kdenetwork-2.2.orig/ksirc/ksircprocess.cpp	Thu Aug 16 19:28:08 2001
+++ kdenetwork-2.2/ksirc/ksircprocess.cpp	Thu Aug 16 19:37:06 2001
@@ -108,6 +108,8 @@
 #include <kstddirs.h>
 #include <kmessagebox.h>
 
+#include <qtextcodec.h>
+
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
@@ -289,11 +291,18 @@
 }
 
 void KSircProcess::new_toplevel(QString str)
+// str is expected to be a unicode string
 {
   static time_t last_window_open = 0;
   static int number_open = 0;
   static bool flood_dlg = FALSE;
 
+static QTextCodec *codec1 = QTextCodec::codecForLocale();
+static QTextCodec *codec2 = QTextCodec::codecForName("ISO-2022-JP");
+cout << "new_toplevel: str = [" << codec1->fromUnicode(str) << "]\n";
+cout << "new_toplevel: str = [" << codec2->fromUnicode(str) << "]\n";
+cout << "new_toplevel: str.length() = [" << str.length() << "]\n";
+
   if(running_window == FALSE){ // If we're not fully running, reusing
 			       // !default window for next chan.
     running_window = TRUE;
@@ -336,7 +345,8 @@
 
     // Create a new toplevel, and add it to the toplist.
     // TopList is a list of KSircReceivers so we still need wm.
-    KSircTopLevel *wm = new KSircTopLevel(this, str.ascii(), (QString(server) +"_" + str).ascii() );
+//    KSircTopLevel *wm = new KSircTopLevel(this, str.ascii(), (QString(server) +"_" + str).ascii() );
+    KSircTopLevel *wm = new KSircTopLevel(this, str.utf8(), (QString(server) +"_" + str) );
     TopList.insert(str, wm);
 
     // Connect needed signals.  For a message window we never want it
@@ -345,8 +355,8 @@
 	    iocontrol, SLOT(stdin_write(QString)));
     connect(wm, SIGNAL(open_toplevel(QString)),
 	    this,SLOT(new_toplevel(QString)));
-    connect(wm, SIGNAL(closing(KSircTopLevel *, char *)),
-	    this,SLOT(close_toplevel(KSircTopLevel *, char *)));
+    connect(wm, SIGNAL(closing(KSircTopLevel *, const char *)),
+	    this,SLOT(close_toplevel(KSircTopLevel *, const char *)));
     connect(wm, SIGNAL(currentWindow(KSircTopLevel *)),
 	    this,SLOT(default_window(KSircTopLevel *)));
     connect(wm, SIGNAL(changeChannel(const QString &, const QString &)),
@@ -364,7 +374,7 @@
   }
 }
 
-void KSircProcess::close_toplevel(KSircTopLevel *wm, char *name)
+void KSircProcess::close_toplevel(KSircTopLevel *wm, const char *name)
 {
   bool is_default = FALSE; // Assume it's no default
   QString qname = name;
@@ -382,6 +392,7 @@
   if(TopList.count() <= 8){ // If this is the last window shut down
     QString command = "/quit\n";
     iocontrol->stdin_write(command); // kill sirc
+    cout << "*** A ***\n";
     if ( guardedwm )
     delete wm;
     delete this; // Delete ourself, WARNING MUST RETURN SINCE WE NO
@@ -419,6 +430,7 @@
       TopList.remove("!default");   // let's not blow up to badly
       QString command = "/signoff\n";  // close this server connetion then
       iocontrol->stdin_write(command); // kill sirc
+cout << "*** B ***\n";
       delete wm;
       delete this; // Delete ourself, WARNING MUST RETURN SINCE WE NO
                    // LONGER EXIST!!!!
@@ -436,9 +448,10 @@
       auto_create_really = FALSE;
   }
 
+cout << "*** C ***\n";
   delete wm; /* deletes char *name */
   emit ProcMessage(QString(server), ProcCommand::deleteTopLevel,
-                   qname);
+                   QString::fromUtf8(qname));
 }
 
 void KSircProcess::clean_toplevel(KSircTopLevel *clean){
diff -urN kdenetwork-2.2.orig/ksirc/ksircprocess.h kdenetwork-2.2/ksirc/ksircprocess.h
--- kdenetwork-2.2.orig/ksirc/ksircprocess.h	Thu Aug 16 19:28:08 2001
+++ kdenetwork-2.2/ksirc/ksircprocess.h	Thu Aug 16 19:37:06 2001
@@ -31,7 +31,7 @@
  virtual void ServMessage(QString server, int command, QString args);
  virtual void new_toplevel(QString);
  //  virtual void new_ksircprocess(QString);
- virtual void close_toplevel(KSircTopLevel *, char *);
+ virtual void close_toplevel(KSircTopLevel *, const char *);
  virtual void default_window(KSircTopLevel *);
  virtual void recvChangeChannel(const QString &, const QString &);
 
diff -urN kdenetwork-2.2.orig/ksirc/servercontroller.cpp kdenetwork-2.2/ksirc/servercontroller.cpp
--- kdenetwork-2.2.orig/ksirc/servercontroller.cpp	Thu Aug 16 19:28:08 2001
+++ kdenetwork-2.2/ksirc/servercontroller.cpp	Thu Aug 16 19:37:06 2001
@@ -518,7 +518,7 @@
       char *new_s, *old_s;
       new_s = new char[args.length()];
       old_s = new char[args.length()];
-      sscanf(args.ascii(), "%s %s", old_s, new_s);
+      sscanf(args.utf8(), "%s %s", old_s, new_s);
       //  If the channel has a !, it's a control channel, remove the !
       if(old_s[0] == '!')
         // Even though, we want strlen() -1 characters, strlen doesn't
@@ -527,9 +527,9 @@
       if(new_s[0] == '!')
 	memmove(new_s, new_s, strlen(new_s)); // See above for strlen()
 
-      item = findChild( serverItem, old_s );
+      item = findChild( serverItem, QString::fromUtf8(old_s) );
       delete item;
-      item = new QListViewItem( serverItem, new_s );
+      item = new QListViewItem( serverItem, QString::fromUtf8(new_s) );
       item->setPixmap( 0, *pic_ppl );
 
       delete[] new_s;
diff -urN kdenetwork-2.2.orig/ksirc/toplevel.cpp kdenetwork-2.2/ksirc/toplevel.cpp
--- kdenetwork-2.2.orig/ksirc/toplevel.cpp	Thu Aug 16 19:28:08 2001
+++ kdenetwork-2.2/ksirc/toplevel.cpp	Thu Aug 16 19:37:06 2001
@@ -65,9 +65,12 @@
 #include <klocale.h>
 #include <kglobal.h>
 #include <kfiledialog.h>
+#include <kcharsets.h>
 
 #include <kdebug.h>
 
+#include <qtextcodec.h>
+
 extern KConfig *kConfig;
 extern KApplication *kApp;
 extern DisplayMgr *displayMgr;
@@ -103,7 +106,7 @@
 KSircTopLevel::KSircTopLevel(KSircProcess *_proc, const char *cname, const char * name)
     : KMainWindow(0, name, 0 /* no WDestructiveClose! */),
       KSircMessageReceiver(_proc)
-
+// cname is expected to be a utf8 string
 {
     // prevent us from being quitted when closing a channel-window. Only
     // closing the servercontroller shall quit.
@@ -124,15 +127,17 @@
   QString kstl_name = QString(QObject::name()) + "_" + "toplevel";
   setName(kstl_name);
 
-  channel_name = qstrdup(cname);
+  QTextCodec *codec = QTextCodec::codecForName("ISO-2022-JP");
+
+  channel_name = codec->toUnicode(QString::fromUtf8(cname));
   if(channel_name){
   //    QString s = channel_name;
   //    int pos2 = s.find(' ', 0);
   //    if(pos2 > 0)
   //      channel_name = qstrdup(s.mid(0, pos2).data());
 
-    setCaption(channel_name);
     caption = channel_name;
+    setCaption(caption);
   }
   else
     caption = "";
@@ -381,8 +386,7 @@
   ticker = 0;
   delete user_controls;
   delete ChanParser;
-  free( channel_name );
-  channel_name = 0;
+cout << "leaving ~KSircTopLevel() ... \n";
 }
 
 void KSircTopLevel::show()
@@ -487,6 +491,11 @@
    */
   int lines = 0;
 
+QTextCodec *codec = QTextCodec::codecForName("ISO-2022-JP");
+//cout << "sirc_receive: str = " << codec->fromUnicode(str) << "\n";
+cout << "sirc_receive: 0: str = " << str << "\n";
+cout << "sirc_receive: 1: str.isEmpty() = " << str.isEmpty() << "\n";
+
   if(Buffer == FALSE){
     if(LineBuffer.count() >= 2){
       //mainw->setAutoUpdate(FALSE);
@@ -513,7 +522,9 @@
 
         // Get the need list box item, with colour, etc all set
         string = line.message;
+cout << "sirc_receive: string = " << codec->fromUnicode(string) << "\n";
         item = parse_input(string);
+
         // If we shuold add anything, add it.
         // Item might be null, if we shuoold ingore the line
 
@@ -523,6 +534,7 @@
                     item, SLOT(updateSize()));
             connect(this, SIGNAL(freezeUpdates(bool)),
                     item, SLOT(freeze(bool)));
+// cout << "sirc_receive: item->getText() = " << codec->fromUnicode(item->getText()) << "\n";
             mainw->insertItem(item, -1);
             if(ticker){
                 QString text;
@@ -532,6 +544,7 @@
                     text.prepend("~");
                 }
                 text.append(item->getText());
+// cout << "sirc_receive: text = " << codec->fromUnicode(text) << "\n";
                 ticker->mergeString(text + "~C // ");
             }
             lines++; // Mode up lin counter
@@ -552,7 +565,7 @@
            mainw->removeItem(0);
     }
 
-    //mainw->setAutoUpdate(TRUE);
+//    mainw->setAutoUpdate(TRUE);
 
     mainw->scrollToBottom();
     mainw->repaint(FALSE); // Repaint, but not need to erase and cause fliker.
@@ -634,13 +647,17 @@
       // In case of a channel key, first join and then open
       // the toplevel, to avoid a "Could not join, wrong key"
       // when the new toplevel emits a /join on activation
+static QTextCodec *codec = QTextCodec::codecForName("ISO-2022-JP");
+//cout << "sirc_write: name = [" << codec->fromUnicode(name) << "]\n";
       if(name[0] != '#'){
+//        emit open_toplevel(codec->fromUnicode(name));
         emit open_toplevel(name);
         linee->setText("");
         return;
       }
       else {
         emit outputLine(str + "\n");
+//        emit open_toplevel(codec->fromUnicode(name));
         emit open_toplevel(name);
       }
       // Finish sending /join
@@ -710,6 +727,9 @@
    * No-output get's set to 1 if we should ignore the line
    */
 
+QTextCodec *codec = QTextCodec::codecForName("ISO-2022-JP");
+cout << "parse_input: string = " << codec->fromUnicode(string) << "\n";
+
   /*
    * This is the second generation parsing code.
    * Each line type is determined by the first 3 characters on it.
@@ -735,6 +755,7 @@
   }
   else
   {
+// cout << "parse_input: else: string = " << codec->fromUnicode(string) << "\n";
     result = new ircListItem(string, kSircConfig->colour_text, mainw, 0);
   }
   delete pResult;
@@ -841,7 +862,8 @@
   hide();
   qApp->flushX();
   // Let's say we're closing, what ever connects to this should delete us.
-  emit closing(this, channel_name);
+  const char *channel_name_utf8 = channel_name.utf8();
+  emit closing(this, channel_name_utf8);
 }
 
 void KSircTopLevel::resizeEvent(QResizeEvent *e)
@@ -857,7 +879,7 @@
   if(isVisible() == TRUE){
     if(have_focus == 0){
       if(channel_name[0] == '#'){
-        QString str = "/join " + QString(channel_name) + "\n";
+        QString str = "/join " + channel_name + "\n";
         emit outputLine(str);
 		emit outputLine("/eval $query=''\n");
       }
@@ -882,6 +904,10 @@
 
 void KSircTopLevel::control_message(int command, QString str)
 {
+// cout << "control_message: command = " << command << "\n";
+//QTextCodec *codec = QTextCodec::codecForLocale();
+//cout << "control_message: str = " << str << "\n";
+//cout << "control_message: codec->fromUnicode(str) = " << codec->fromUnicode(str) << "\n";
   switch(command){
   case CHANGE_CHANNEL: // 001 is defined as changeChannel
     {
@@ -903,10 +929,14 @@
           chan = str.mid(bang + 3, str.length() - (bang + 3));
       }
       emit changeChannel(channel_name, chan);
+//cout << "control_message: chan = " << chan << "\n";
+//cout << "control_message: codec->fromUnicode(chan) = " << codec->fromUnicode(chan) << "\n";
+#if 0
       if(channel_name)
         delete channel_name;
-      channel_name = qstrdup(chan.ascii());
-      setName(server + "_" + QString(channel_name) + "_" + "toplevel");
+#endif
+      channel_name = chan;
+      setName(server + "_" + channel_name + "_" + "toplevel");
       f->setName(QString(QString(QObject::name()) + "_" + "kstIFrame"));
       kmenu->setName(QString(QObject::name()) + "_ktoolframe");
       linee->setName(QString(QObject::name()) + "_" + "LineEnter");
@@ -1056,6 +1086,7 @@
       return QString::null;
   }
   return part;
+
 
 }
 
diff -urN kdenetwork-2.2.orig/ksirc/toplevel.h kdenetwork-2.2/ksirc/toplevel.h
--- kdenetwork-2.2.orig/ksirc/toplevel.h	Thu Aug 16 19:28:08 2001
+++ kdenetwork-2.2/ksirc/toplevel.h	Thu Aug 16 19:37:06 2001
@@ -124,7 +124,7 @@
     * this window is closing. Refrence to outselves
     * is include.
     */
-  void closing(KSircTopLevel *, char *);
+  void closing(KSircTopLevel *, const char *);
   /**
     * emitted when we change channel name
     * on the fly.  old is the old channel name, new
@@ -390,7 +390,7 @@
   /**
     * The channel name that we belong too.
     */
-  char *channel_name;
+  QString channel_name;
 
   /**
     * Caption at the top of the window.
