Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]how to convert this IRI to URI ?
Forum Updated to NodeBB v4.3 + New Features

[Solved]how to convert this IRI to URI ?

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 3.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    redstoneleo
    wrote on last edited by
    #1

    how to convert this IRI to URI ?

    http://down.qnwz.cn/uploads/media/broadcast/storymagazine/爱情的底牌.mp3

    I hope the result type should be Qurl ,thanks

    it seems that
    @QUrl QUrl::fromEncoded ( const QByteArray & input )@
    doesn’t work here .

    @

    from PyQt4.QtCore import *
    url='http://down.qnwz.cn/uploads/media/broadcast/storymagazine/爱情的底牌.mp3'
    QUrl.fromEncoded (QUrl(url).toEncoded())
    PyQt4.QtCore.QUrl('http://down.qnwz.cn/uploads/media/broadcast/storymagazine/爱情的底牌.mp3')

    @

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      try "QUrl::toPercentEncoding()":http://qt-project.org/doc/qt-5.0/qtcore/qurl.html#toPercentEncoding

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • R Offline
        R Offline
        redstoneleo
        wrote on last edited by
        #3

        [quote author="raven-worx" date="1371191655"]try "QUrl::toPercentEncoding()":http://qt-project.org/doc/qt-5.0/qtcore/qurl.html#toPercentEncoding[/quote]
        it only return a QByteArray ,but I hope the result type should be Qurl

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dbzhang800
          wrote on last edited by
          #4

          IMO, if you can make sure that the string you passed to QUrl is a unicode string, then it will work.

          For example, if you are using Python 2's shell under Windows platform, you can give a try to

          @
          QUrl('http://down.qnwz.cn/uploads/media/broadcast/storymagazine/爱情的底牌.mp3'.decode('gbk'))
          @

          1 Reply Last reply
          0
          • raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

            [quote author="redstoneleo" date="1371198034"]
            it only return a QByteArray ,but I hope the result type should be Qurl [/quote]
            did you look at the example in the docs of this function?!

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • R Offline
              R Offline
              redstoneleo
              wrote on last edited by
              #6

              [quote author="1+1=2" date="1371198201"]IMO, if you can make sure that the string you passed to QUrl is a unicode string, then it will work. For example, if you are using Python 2's shell under Windows platform, you can give a try to @ QUrl('http://down.qnwz.cn/uploads/media/broadcast/storymagazine/爱情的底牌.mp3'.decode('gbk')) @[/quote]

              谢谢了,只不过我用的是python3

              P.S.前辈您即能搞C++又能Python ,还是Qt已认证后的专家,高手也!!

              我喜欢数学、物理、编程(主要是Python)、动漫、看杂志,有兴趣可以加QQ2281570025交流下。

              1 Reply Last reply
              0
              • R Offline
                R Offline
                redstoneleo
                wrote on last edited by
                #7

                here is the answer
                http://stackoverflow.com/questions/17100637/how-to-convert-this-iri-to-uri/17102576?noredirect=1#17102576

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved