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. QStringLiteral - mingw vs. msvc
Forum Updated to NodeBB v4.3 + New Features

QStringLiteral - mingw vs. msvc

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 377 Views 2 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.
  • HoMaH Offline
    HoMaH Offline
    HoMa
    wrote on last edited by
    #1
    QString t =QLatin1String("QLatin1String    : äöüß@\\~ÄÜÖ\n");
    t +=QStringLiteral(      "QStringLiteral   : äöüß@\\~ÄÜÖ\n");
    t +=QStringLiteral(     u"QStringLiteral(u): äöüß@\\~ÄÜÖ\n");
    t +=QString(             "QString          : äöüß@\\~ÄÜÖ\n");
    
    ui->textEdit->setText(t);
    

    Hi all - from the beginning I had the impression, that I do not understand this QStringLiteral thing ... now I found out that this little piece of code gives different result for mingw and msvc build (on Windows, both 64 bit builds in Qt Creator 4.13.0
    Based on Qt 5.15.0 (MSVC 2019, 64 bit)).
    MinGw looks actually OK (see below) but with msvc only the last line looks OK - all others look like the first one. Can someone explain?

    mingw64.PNG

    1 Reply Last reply
    0
    • JohanSoloJ Offline
      JohanSoloJ Offline
      JohanSolo
      wrote on last edited by
      #2

      What is the encoding of your source file? If the file is UTF-8, I don't expect your Latin1 string to be properly displayed...

      `They did not know it was impossible, so they did it.'
      -- Mark Twain

      1 Reply Last reply
      1
      • HoMaH Offline
        HoMaH Offline
        HoMa
        wrote on last edited by
        #3

        @JohanSolo : This is the right track! I found this historic post in a german qt forum which proposes to use a /utf8 switch on the compiler. It is actually /utf-8 - but it works like a charm!
        I learned that one can put compiler options into the .pro file like this:

        ...
        QMAKE_CXXFLAGS = /utf-8
        ...
        

        So: problem solved!
        One more note: I think I did not notice this before because my PC was configured with german as the UI / explorer / shell language and I changed to english a while ago. I guess this made a difference, too (besides switching from mingw to msvc

        1 Reply Last reply
        2

        • Login

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