diff -Naur kdebase-3.5.0-orig/kioslave/man/kio_man.cpp kdebase-3.5.0/kioslave/man/kio_man.cpp --- kdebase-3.5.0-orig/kioslave/man/kio_man.cpp 2005-10-10 19:04:01 +0400 +++ kdebase-3.5.0/kioslave/man/kio_man.cpp 2006-01-01 19:49:28 +0300 @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include @@ -566,6 +568,51 @@ if (array.isEmpty()) return 0; + + //-------- Make locale encoded manpage text --------------------------------- + QTextCodec *loc_codec = QTextCodec::codecForLocale(); + if (loc_codec) { + QTextCodec *man_codec = 0; + + // Try .charmap file in manpage dir + QFileInfo fi(QFile::decodeName(_filename)); + QFile file(fi.dirPath(true).replace(QRegExp("/man\\w$"),"/.charset")); + + if ( file.open( IO_ReadOnly ) ) { + QTextStream stream( &file ); + QString man_charmap; + + man_charmap = stream.readLine(); // line of text excluding '\n' + file.close(); + if (!man_charmap.isEmpty()) { + man_codec = QTextCodec::codecForName(man_charmap.latin1()); + } + } + + // Can't find .charmap file or its empty. Try environment + // variable + if(!man_codec) { + char *env = getenv("MAN_ICONV_INPUT_CHARSET"); + if(env && *env) + man_codec = QTextCodec::codecForName(env); + } + + // No manpage charmap specified, use UTF-8 as default + //if(!man_codec) + // man_codec = QTextCodec::codecForMib(106); + + if(man_codec) { + if (loc_codec->mibEnum()!=man_codec->mibEnum()) { + // Locale has difer charmap than manpage + QString unicode; + + kdDebug(7107) << "recode " << man_codec->name() << " to " << loc_codec->name() << endl; + unicode = man_codec->toUnicode(array); + array = loc_codec->fromUnicode(unicode); + } + } + } + //-------------------------------------------------------------------------- const int len = array.size(); buf = new char[len + 4];