From 8d4eeb581f8d467a8f8608953154ea82d3026e5b Mon Sep 17 00:00:00 2001 From: xiaoyifang Date: Fri, 22 Nov 2024 11:35:22 +0800 Subject: [PATCH] fix: dsl ann file codec detection --- src/common/utils.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/utils.cc b/src/common/utils.cc index ccc6a8f2..4a2569aa 100644 --- a/src/common/utils.cc +++ b/src/common/utils.cc @@ -50,9 +50,10 @@ QString unescapeAmps( QString const & str ) QTextCodec::Encoding detectCodec( QByteArray & ba, char16_t expectedFirstCharacter = 0 ) { - QStringConverter::Encoding detectedEncoding = QStringConverter::encodingForData( data, expectedFirstCharacter ); + QStringConverter::Encoding detectedEncoding = detectEncoding( ba, expectedFirstCharacter ); // mapping the encoding - if ( detectedEncoding.has_value() && encodingMap.contains( detectedEncoding.value() ) ) { + if (encodingMap.contains( detectedEncoding ) ) + { return encodingMap[ encoding ]; } // default utf8 @@ -62,7 +63,6 @@ QTextCodec::Encoding detectCodec( QByteArray & ba, char16_t expectedFirstCharact QStringConverter::Encoding detectEncoding( QByteArray & ba, char16_t expectedFirstCharacter = 0 ) { QStringConverter::Encoding detectedEncoding = QStringConverter::encodingForData( data, expectedFirstCharacter ); - // mapping the encoding if ( detectedEncoding.has_value() ) { return detectedEncoding.value(); }