Is there a thrid lib can suppor soft decode music named chinese?
-
Hi! Are you sure libzplay cannot handle paths containing non ASCII characters? Did you try to find out what exactly was the problem? How are you handling the paths? What data type do you use for paths (char*, std::string, ...)?
-
Hi! Are you sure libzplay cannot handle paths containing non ASCII characters? Did you try to find out what exactly was the problem? How are you handling the paths? What data type do you use for paths (char*, std::string, ...)?
@jsulm my code is this. Whan I call player->open ,it will fail;
QStringList fileNames=QFileDialog::getOpenFileNames(this,
tr("Open file"),
musicPaths.isEmpty() ? QDir::homePath() : musicPaths.first(),
tr("MP3 files (.mp3 .wav);;All files (.)"));foreach(QString file,fileNames)
{
QByteArray ba = file.toLocal8Bit();
const char * name = ba.data();ZPlay *player = CreateZPlay(); if(player->OpenFile(name, sfAutodetect) == 0) { qDebug()<<QString("Error: %1 \nPress key to exit.\r\n").arg(player->GetError()); // getch(); player->Release(); return false; }
.......
} -
@jsulm my code is this. Whan I call player->open ,it will fail;
QStringList fileNames=QFileDialog::getOpenFileNames(this,
tr("Open file"),
musicPaths.isEmpty() ? QDir::homePath() : musicPaths.first(),
tr("MP3 files (.mp3 .wav);;All files (.)"));foreach(QString file,fileNames)
{
QByteArray ba = file.toLocal8Bit();
const char * name = ba.data();ZPlay *player = CreateZPlay(); if(player->OpenFile(name, sfAutodetect) == 0) { qDebug()<<QString("Error: %1 \nPress key to exit.\r\n").arg(player->GetError()); // getch(); player->Release(); return false; }
.......
}@chaochao said in Is there a thrid lib can suppor soft decode music named chinese?:
QByteArray ba = file.toLocal8Bit();
Please read the documentation (http://doc.qt.io/qt-5/qstring.html#toLocal8Bit):
"The returned byte array is undefined if the string contains characters not supported by the local 8-bit encoding."
8bit encoding cannot represent Unicode!You have to use http://doc.qt.io/qt-5/qstring.html#toUtf8
-
@chaochao said in Is there a thrid lib can suppor soft decode music named chinese?:
QByteArray ba = file.toLocal8Bit();
Please read the documentation (http://doc.qt.io/qt-5/qstring.html#toLocal8Bit):
"The returned byte array is undefined if the string contains characters not supported by the local 8-bit encoding."
8bit encoding cannot represent Unicode!You have to use http://doc.qt.io/qt-5/qstring.html#toUtf8