Репозиторий ALT Linux backports/2.4
Последнее обновление: 9 июля 2008 | Пакетов: 497 | Посещений: 1652626
 поиск   регистрация   авторизация 
 
Группа :: Графические оболочки/KDE
Пакет: kdebase

 Главная   Изменения   Спек   Патчи   Загрузить   Bugs and FR 

Патч: kdebase-3.1.3-man_recode.patch


diff -Naur kdebase-3.1.3.orig/kioslave/man/kio_man.cpp kdebase-3.1.3/kioslave/man/kio_man.cpp
--- kdebase-3.1.3.orig/kioslave/man/kio_man.cpp	2003-07-13 23:24:04 +0400
+++ kdebase-3.1.3/kioslave/man/kio_man.cpp	2003-08-13 17:08:48 +0400
@@ -29,6 +29,8 @@
 #include <qptrlist.h>
 #include <qmap.h>
 #include <qregexp.h>
+#include <qtextcodec.h>
+#include <qfileinfo.h>
 
 #include <kdebug.h>
 #include <kinstance.h>
@@ -490,6 +492,51 @@
 
     delete fd;
 
+    //-------- 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(text);
+                text    = loc_codec->fromUnicode(unicode);
+            }
+        }
+    }
+    //--------------------------------------------------------------------------
+
     int l = text.length();
 	buf = new char[l + 4];
     memcpy(buf + 1, text.data(), l);
 
design & coding: Vladimir Lettiev aka crux © 2004-2005