Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-125380

Windows command line arguments mangled by double prime character

    XMLWordPrintable

Details

    • Windows
    • 993b197d9 (dev), 34533705b (6.8), a5fdbd73a (6.7), 96d41da6b (tqtc/lts-6.5)

    Description

      The Unicode double prime character, U+2033, is somehow confusing QCoreApplication's argument handling. Unicode characters in arguments normally work fine, because Qt tries to detect if the arguments passed into QCoreApplication's constructor were modified versus the arguments used to start the process. If no changes are detected, it fetches them from GetCommandLineW instead. I believe the arguments Qt is capturing at the entry point may have subtle differences in certain cases, to the arguments used for comparison when checking for modifications. Using this sample project:

      QT += widgets
      SOURCES += main.cpp

      And code file:

      #include <QApplication>
      #include <QMessageBox>
      #include <QProcess>
      #include <QStringList>
      #include <Windows.h>
      
      int main(int argc, char *argv[]) {
          QApplication app(argc, argv);
          if (app.arguments().size() > 1) {
              QMessageBox::information(nullptr, "QApplication Argument", app.arguments().at(1));
              QMessageBox::information(nullptr, "GetCommandLineW", QString::fromWCharArray(GetCommandLineW()));
          } else {
              // No arguments provided, relaunch the application with default argument
              QString program = app.arguments().at(0);
              QStringList arguments("The double prime symbol \u2033 is used to represent inches. And this \u30C4 is a Japanese smiley.");
              QProcess::startDetached(program, arguments);
          }
          return 0;
      }

      In first message box displayed, the double prime is shown as a plain quotation mark, and the Japanese character is shown as a question mark. Try changing \u2033 to \u2034 (triple prime) or most other Unicode characters and it works fine. MSVC 2019 and en-US in case that matters.

      Some users apparently use these symbols in directory or file names, and then have trouble opening the file with a Qt application.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            jdpurcell J.D. Purcell
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes