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. Handling of Surrogate Pair Characters
Forum Updated to NodeBB v4.3 + New Features

Handling of Surrogate Pair Characters

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 224 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.
  • M Offline
    M Offline
    m.kawakami
    wrote on last edited by
    #1

    Can I receive a file name with surrogate pair characters in the argument and open the file correctly with QFile, for example?
    I'm having trouble with the surrogate pair characters being garbled as shown below.

    "𩸽.txt" -> "??.txt"

    // Run example.   test.exe 𩸽.txt
    int main(int argc, char* argv[])
    {
        QFile file(argv[1]);
        if (!file.open(QIODevice::WriteOnly)) {
            // open failed.
        }
    }
    

    The following is environmental information.

    • Windows 10
    • Qt 5.15.5
    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You must not simply convert a char* to a QString - how should QString should know the enconding about the char*?
      Use a Q(Core)Application and read the arguments from there - then they should be properly encoded.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      4
      • M Offline
        M Offline
        m.kawakami
        wrote on last edited by
        #3

        Thank you for your response.
        You've been very helpful.

        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