In the file is stored information about Name and Vendor name of application (Symbian OS). And i want get this informations. Following code
void GetData()
{
if (sub->exists()){
return;
}
int findvendor
= data.
indexOf(QByteArray::fromHex("0000"),
32);
for (int i = 32; i<findvendor; i++){
vendorList << reinterpret_cast<const char*>(&data.constData()[i]);
}
vendor = vendorList.join(" ").replace(" ", "");
int beginName
= data.
indexOf(QByteArray::fromHex("0001"), findvendor
)+8;
int endName
= data.
indexOf(QByteArray::fromHex("0000"), beginName
);
for (int i = beginName; i<endName; i++){
nameList << reinterpret_cast<const char*>(&data.constData()[i]);
}
qDebug() << nameList;
name
= nameList.
join(" ").
replace(" ",
"").
replace(QChar(0x00
),
"").
replace(QChar(0x0c
),
"").
replace(QChar(0x02
),
"");
}else{
name = tr("Unknown");
vendor = tr("Unknown");
}
qDebug() << name << '\n' << vendor;
delete sub;
}
void GetData()
{
QFile *sub = new QFile(QString("c:\\TestFile.ctl"));
if (sub->exists()){
if (!sub->open(QIODevice::ReadOnly)){
return;
}
QByteArray data = sub->read(200);
int findvendor = data.indexOf(QByteArray::fromHex("0000"), 32);
QStringList vendorList;
for (int i = 32; i<findvendor; i++){
vendorList << reinterpret_cast<const char*>(&data.constData()[i]);
}
vendor = vendorList.join(" ").replace(" ", "");
int beginName = data.indexOf(QByteArray::fromHex("0001"), findvendor)+8;
int endName = data.indexOf(QByteArray::fromHex("0000"), beginName);
QStringList nameList;
for (int i = beginName; i<endName; i++){
nameList << reinterpret_cast<const char*>(&data.constData()[i]);
}
qDebug() << nameList;
name = nameList.join(" ").replace(" ", "").replace(QChar(0x00), "").replace(QChar(0x0c), "").replace(QChar(0x02), "");
}else{
name = tr("Unknown");
vendor = tr("Unknown");
}
qDebug() << name << '\n' << vendor;
delete sub;
}
To copy to clipboard, switch view to plain text mode
works fine until file doesn't contain UTF-8 chars.
Here is the two files. One is without UTF-8 and one with UTF-8 chars.
TestFiles.zip
Bookmarks