Qt 6 way of saving a Unicode string to QSettings – Is this a bug or a feature?!
-
Hi all :-)
I save one single char as a symbol in a
QSettings
key. Apparently, the way Qt 6 saves such a string is different from Qt 5:The default symbol I use is
QStringLiteral("\u25CF")
, "BLACK CIRCLE". When I save this using Qt 5 (by usingsetValue(s_symbol, text)
), the following appears in my config file:symbol=\x25cf
When I build my program using Qt 6, this is – without calling the respective save method, silently! – changed to it's literal Unicode representation, and I get:
symbol=●
When using the same config again with a Qt 5 build, this is read and displayed as (using
symbol = value(s_symbol, DefaultValues::symbol).toString()
):â
(an
â
followed by two boxes). And again, without calling the save method, this is silently changed tosymbol=\xe2\x97\x8f
The problem is that I can't detect if the symbol is what it should be, or if it has been "messed up" by Qt 6.
So: Is this a bug or a feature?! And if it's the latter: Is there any way to force Qt 6 to save the escaped version that can also be read by Qt 5?
Thanks for all help!
Cheers, Tobias!
-
Qt6 assumes that the ini-file is utf-8 encoded so a hex encoding is no longer needed. This is not backwards compatible but consistent.
-
L l3u_ has marked this topic as solved on
-
@Christian-Ehrlicher Oh, I just realized you said that INI files are assumed to be UTF-8 – does this mean the change does not affect Windows, where the settings are stored in the registry?
-
It should not as the registry should be unicode