Skip to content

Commit d37fea5

Browse files
committed
remove byte order mark for UTF 16 and 32 encoding
1 parent 5caf7d5 commit d37fea5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

locfilesystemmodel.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ QVariant LocFileSystemModel::data(const QModelIndex &index, int role) const{
1616
//did I want to add some other check here?
1717
if(role==Qt::DisplayRole&&codec&&systemcodec){
1818
QByteArray str=systemcodec->fromUnicode(dat.toString());
19+
QByteArray cname=systemcodec->name();
20+
if(cname=="UTF-16"||cname=="UTF-16LE"||cname=="UTF-16BE"){
21+
str.remove(0,2);//remove byte order mark
22+
}
23+
else if(cname=="UTF-32"||cname=="UTF-32LE"||cname=="UTF-32BE"){
24+
str.remove(0,4);//remove byte order mark
25+
}
1926
dat=QVariant(codec->toUnicode(str));
2027
}
2128
return dat;

0 commit comments

Comments
 (0)