From 2cc68eae6944d8d0845eaf2d6dbb857baa288c86 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Sun, 18 Oct 2015 15:28:37 +0300 Subject: [PATCH] okular: use QTextCodec instead of KEncodingProber for unicode conversion of text --- okular/generators/txt/document.cpp | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/okular/generators/txt/document.cpp b/okular/generators/txt/document.cpp index 29aa2db3..e62211ff 100644 --- a/okular/generators/txt/document.cpp +++ b/okular/generators/txt/document.cpp @@ -12,7 +12,6 @@ #include #include -#include #include #include "document.h" @@ -42,30 +41,6 @@ Document::~Document() QString Document::toUnicode( const QByteArray &array ) { - QByteArray encoding; - KEncodingProber prober(KEncodingProber::Universal); - int charsFeeded = 0; - int chunkSize = 3000; // ~= number of symbols in page. - - // Try to detect encoding. - while ( encoding.isEmpty() && charsFeeded < array.size() ) - { - prober.feed( array.mid( charsFeeded, chunkSize ) ); - charsFeeded += chunkSize; - - if (prober.confidence() >= 0.5) - { - encoding = prober.encoding(); - break; - } - } - - if ( encoding.isEmpty() ) - { - return QString(); - } - - kDebug() << "Detected" << prober.encoding() << "encoding" - << "based on" << charsFeeded << "chars"; - return QTextCodec::codecForName( encoding )->toUnicode( array ); + QTextCodec *codec = QTextCodec::codecForUtfText(array); + return codec->toUnicode( array ); } -- 2.11.0