Skip to content
  • 1 Votes
    5 Posts
    3k Views
    D

    Normal C strings don't support unicode, so doing QString("\u2060") will give a compiler warning saying "C4566: character represented by universal-character-name '\u2060' cannot be represented in the current code page (1252)", and will replace the \u2060 characters with question marks.

    Instead, it works to do:

    QString("Défaut suspension: Limitez votre vitesse à 90km") + QChar(0x2060) + "/" + QChar(0x2060) + "h"

    Or, if that's too difficult to read, this also works:

    QString("Défaut suspension: Limitez votre vitesse à 90km\1/\1h").replace('\1', QChar(0x2060))
  • 0 Votes
    11 Posts
    6k Views
    E

    [SOLVED]

    Eventually, the solution is to add escape character '' before any special character which has a unicode between 161 and 255 (including).

    E.g. "abékl" -> "ab\ékl"

    When looking into Qt source code and specifically to int QCssScanner_Generated::lex() (qcssscanner.cpp) one can find a huge state machine parser (css based) which expects the escape character before unicode characters 161 to 255.
    (the parser get called by QWidget::setStyleSheet eventually)

    The reason Japanese, Chinese and more non-Latin languages worked is because the state machine handles unicode characters from 256 above as is (does not expect the escape).

    Hope this will help others.

    p.s.
    Using QString::fromLatin1() didn't help.