Recode man output from current locale encoding (or from .charset file in manpages directory, or value MAN_ICONV_INPUT_CHARSET environment variable) into UTF-8 encoding for correct representation by konqueror 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 <qptrlist.h> #include <qmap.h> #include <qregexp.h> +#include <qtextcodec.h> +#include <qfileinfo.h> #include <kdebug.h> #include <kinstance.h> @@ -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];
Don't restrict bugs without any reason. Just leave the checkboxes alone, please.
Please take this upstream...
Sorry, I was supposed to look into this.
Created attachment 102964 [details, diff] Forces kioproc to use codec for current locale instead of ISO-8859-1
Created attachment 102965 [details, diff] orrects UTF-8 charset name to charset name current locale in Content-Type builded HTML document
Created attachment 102966 [details, diff] copy of man_recode patch
I author of this patch. Sorry for long delay... Too many work. Some patches on kdelibs also are necessary to you. See attachements. The first patch forces kioproc to use codec for current locale instead of ISO-8859-1 (kdelibs-3.1.2-fix-kprocio-def-codec.patch). The second patch corrects UTF-8 charset name to charset name current locale in Content-Type builded HTML document (kdelibs-3.4.0-ALT-fix-kdoctools-mime-charset.patch). And copy of man_recode patch (kdebase-3.5.0-man_recode.patch)
Created attachment 109936 [details, diff] Patch to document changes in kio_man.cpp Small documentation update to reflect changes done by this patches. BTW. This patches are applied in Altlinux Sisyphus (unstable branch of Altlinux): http://sisyphus.ru/srpm/kdelibs/patches * kdelibs-3.4.0-ALT-fix-kdoctools-mime-charset.patch * kdelibs-3.1.2-fix-kprocio-def-codec.patch and http://sisyphus.ru/srpm/kdebase/patches * kdebase-3.5.0-man_recode.patch I've tested them and these patches work here. Really useful :) Thank you, Sergey.
I'm not fine to include such a patch for this minor functionality, especially since I'm quite sure your patch won't be accepted upstream, as long as it implies adding recode as another dependency to KDE. Please sort this out upstream.
KDE upstream bugzilla link https://bugs.kde.org/show_bug.cgi?id=141340