当前位置:   article > 正文

QString QByteArray urlEncode/urlDecode_qbytearray::topercentencoding

qbytearray::topercentencoding

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]
  • 1
  • 2
  • 3

QUrl 对 url 编解码

QString QUrl::fromPercentEncoding(const QByteArray & input)
QByteArray 
 
QUrl::toPercentEncoding(const QString & input, const QByteArray & exclude = QByteArray(), const QByteArray & include = QByteArray())  [static]
  • 1
  • 2
  • 3
  • 4

测试

    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;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/299640
推荐阅读
相关标签
  

闽ICP备14008679号