赞
踩
QByteArray 对 url 编解码
QByteArray QByteArray::toPercentEncoding(const QByteArray & exclude = QByteArray(), const QByteArray & include = QByteArray(), char percent = '%') const
QByteArray QByteArray::fromPercentEncoding(const QByteArray & input, char percent = '%') [static]
QUrl 对 url 编解码
QString QUrl::fromPercentEncoding(const QByteArray & input)
QByteArray
QUrl::toPercentEncoding(const QString & input, const QByteArray & exclude = QByteArray(), const QByteArray & include = QByteArray()) [static]
测试
QString testStr = "http://music.36testing.com/music/Beyond-光辉岁月-粤语-流行歌曲.mkv";
QByteArray testQUrl2B = QUrl::toPercentEncoding(testStr);
qDebug() << "test QUrl String to ByteArray :" + testQUrl2B;
QString testB2QUrlStr = QUrl::fromPercentEncoding(testQUrl2B);
qDebug() << "test ByteArray to QUrl String :" + testB2QUrlStr;
QByteArray testB = testStr.toUtf8();
qDebug() << "test String to ByteArray :" + testB;
QByteArray testURL = testB.toPercentEncoding();
qDebug() << "test ByteArray to ByteArrayURL :" + testURL;
QByteArray testU2B = QByteArray::fromPercentEncoding(testURL);
qDebug() << "test ByteArrayURL to ByteArray :" + testU2B;
QString testB2S = testU2B;
qDebug() << "test ByteArray to String : " + testB2S;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。