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. How to preserve the char case of host name returned from QUrl::host()?
Qt 6.11 is out! See what's new in the release blog

How to preserve the char case of host name returned from QUrl::host()?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 243 Views
  • 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.
  • S Offline
    S Offline
    Sauntor
    wrote on last edited by Sauntor
    #1

    It seems that QUrl::host() always returned a lower case string, can I get the original host name(keep case unchanged)?

    For example:

    QUrl url("MyProtocol://MyHost/kkkk");
    // the codes which fix this issue go here
    Q_ASSERT(url.host() == "MyHost");
    
    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

      The docs for QUrl refer to RFC 3987:
      ...
      When an IRI uses components of the generic syntax, the component syntax equivalence rules always apply; namely, that the scheme and US-ASCII only host are case insensitive and therefore should be normalized to lowercase. For example, the URI
      "HTTP://www.EXAMPLE.com/" is equivalent to "http://www.example.com/".
      ...

      So the odds are against you finding the original case of the host :-(

      1 Reply Last reply
      4

      • Login

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