I want to get 3rd part softeware can decode music with no-ascll name such as chinese
-
Since you are passing the path to an external library you should call QDir::toNativeSperators use the result to pass the path to
player->OpenFile
-
@SGaist I did that ,but i got a same err. I think the problem is not this.Because when i pass the path like this C:\Users\Public\Music\Sample Music\Sleep Away.mp3 ,it will be ok.But when Sleep Away is replaced with chinese ,it will return err.
-
@chaochao said in I want to get 3rd part softeware can decode music with no-ascll name such as chinese:
when i pass the path like this C:\Users\Public\Music\Sample Music\Sleep Away.mp3 ,it will be ok.But when Sleep Away is replaced with chinese ,it will return err.
What encoding is your filename? UTF-8, or EUC-CN, or GB18030, or something else?
-
@chaochao said in I want to get 3rd part softeware can decode music with no-ascll name such as chinese:
GBK2312
If your filename is not encoded in UTF-8, that means
toUtf8()
will give you the wrong path.Try converting your filename to the GB2312, not UTF-8:
QTextCodec* codec = QTextCodec::codecForName("GB2312"); QByteArray ba = codec->fromUnicode(filename); const char* name = ba.data();
-
@chaochao said in I want to get 3rd part softeware can decode music with no-ascll name such as chinese:
@JKSH as your code ,if i qDebug()<<name;
it will output
C:/Users/Public/Music/Sample Music/????.mp3What do you see if you call
qDebug() << ba
?Does zplay recognize this name?
What happens if you use Windows functions to get the filename? http://stackoverflow.com/questions/3176208/files-in-directory-in-c
-
Don't forget you still need to first convert the path to native separators before passing it to your other library.