我设置了以下代码-
class ID3{
const char* fileName;
TagLib::FileRef *file;
public:
ID3(const char *);
QImage* artwork();
}
ID3::ID3(const char* fileNameStr){
this->fileName = fileNameStr;
this->file = new TagLib::FileRef(fileNameStr);
qDebug()<<fileNameStr; //OUTPUT 2
}
QImage* ID3::artwork(){
QString str = QString::fromLocal8Bit(this->fileName);
qDebug()<<str; //OUTPUT 3
//MORE CODES-------
}
const char * QstrTocChar(QString str){
QByteArray ba = str.toLocal8Bit();
qDebug()<<ba.constData(); //OUTPUT 1
return ba.constData();
}
int main(int argc, char *argv[]){
.
.
.
QString fileName = "C:/Qt/Qt5.0.2/Projects/taglib_test/music files/Muse_-_Madness.mp3";
file = new ID3(QstrTocChar(fileName));
QImage *image = file->artwork();
}
现在当我运行程序时,我得到了这些奇怪的输出
输出 1
C:/Qt/Qt5.0.2/Projects/taglib_test/music files/Muse_-_Madness.mp3
输出 2
????p???e'2/
输出 3
"°í³àpµ˜Æe'2/"
不确定OUTPUT 2但我希望 OUTPUT 3 与OUTPUT 1相同。我是一个Qt新手。非常感谢您在理解这些奇怪的字符编码问题以及如何修复OUTPUT 3方面提供建议/帮助。
谢谢!