fix(index):修改文本文件解析逻辑
一些格式有问题的文件可能会被解析成乱码,因此检测到编码格式有问题则跳过解析。
This commit is contained in:
parent
4029b5ca0a
commit
b71d5cf5a9
|
@ -610,8 +610,10 @@ void FileUtils::getTxtContent(const QString &path, QString &textcontent) {
|
|||
uchardet_data_end(chardet);
|
||||
const char *codec = uchardet_get_charset(chardet);
|
||||
|
||||
if(QTextCodec::codecForName(codec) == 0)
|
||||
if(QTextCodec::codecForName(codec) == nullptr) {
|
||||
qWarning() << "Unsupported Text encoding format" << path << QString::fromLocal8Bit(codec);
|
||||
return;
|
||||
}
|
||||
|
||||
QTextStream stream(encodedString, QIODevice::ReadOnly);
|
||||
stream.setCodec(codec);
|
||||
|
|
Loading…
Reference in New Issue