Skip to content

Commit

Permalink
remove byte order mark for UTF 16 and 32 encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
dennis97519 committed Apr 15, 2018
1 parent 5caf7d5 commit d37fea5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions locfilesystemmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ QVariant LocFileSystemModel::data(const QModelIndex &index, int role) const{
//did I want to add some other check here?
if(role==Qt::DisplayRole&&codec&&systemcodec){
QByteArray str=systemcodec->fromUnicode(dat.toString());
QByteArray cname=systemcodec->name();
if(cname=="UTF-16"||cname=="UTF-16LE"||cname=="UTF-16BE"){
str.remove(0,2);//remove byte order mark
}
else if(cname=="UTF-32"||cname=="UTF-32LE"||cname=="UTF-32BE"){
str.remove(0,4);//remove byte order mark
}
dat=QVariant(codec->toUnicode(str));
}
return dat;
Expand Down

0 comments on commit d37fea5

Please sign in to comment.