From cd41c9eaf1dfcca508cd9e1ff4b4e45655efcfa1 Mon Sep 17 00:00:00 2001 From: zhangpengfei Date: Thu, 14 Jan 2021 20:56:14 +0800 Subject: [PATCH] More text file encoding formats are supported; Update changelog. --- debian/changelog | 13 +++++++++++++ debian/control | 3 ++- libsearch/file-utils.cpp | 19 ++++++++++++++++++- libsearch/libsearch.pro | 2 +- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 86a706a..4ad02ed 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,16 @@ +ukui-search (0.0.1+0114) v101; urgency=medium + + * Bugs fixed. + + -- zhangpengfei Thu, 14 Jan 2021 20:47:42 +0800 + +ukui-search (0.0.1+0113) v101; urgency=medium + + * Bugs fixed. + * Functions perfected. + + -- zhangpengfei Wed, 13 Jan 2021 18:55:43 +0800 + ukui-search (0.0.1+0104) v101; urgency=medium * Initial release. diff --git a/debian/control b/debian/control index b6f85cd..25d2fd7 100644 --- a/debian/control +++ b/debian/control @@ -15,7 +15,8 @@ Build-Depends: debhelper (>=9.0.0), libglib2.0-dev, libkf5windowsystem-dev, libgsettings-qt-dev, - libqt5x11extras5-dev + libqt5x11extras5-dev, + libuchardet-dev Standards-Version: 4.5.0 Homepage: https://www.ukui.org/ Vcs-Git: https://github.com/ukui/ukui-search.git diff --git a/libsearch/file-utils.cpp b/libsearch/file-utils.cpp index b663de2..7fffb5f 100644 --- a/libsearch/file-utils.cpp +++ b/libsearch/file-utils.cpp @@ -10,6 +10,7 @@ #include #include #include +#include "uchardet/uchardet.h" size_t FileUtils::_max_index_count = 0; size_t FileUtils::_current_index_count = 0; unsigned short FileUtils::_index_status = INITIAL_STATE; @@ -512,6 +513,22 @@ void FileUtils::getTxtContent(QString &path, QString &textcontent) QFile file(path); if(!file.open(QIODevice::ReadOnly|QIODevice::Text)) return; - textcontent = QString(file.readAll()).replace("\n",""); + + QByteArray encodedString = file.readAll(); + + uchardet_t chardet = uchardet_new(); + if(uchardet_handle_data(chardet,encodedString.constData(),encodedString.size()) !=0) + qWarning()<<"Txt file encoding format detect fail!"<