Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
What is the correct way of doing setIniCodec("UTF-8") to a QSetting object?
thippu last edited by thippu
I'm using windows and I would like to develop cross-platform
.inifile reading and editing using Qt.
.inifile format is UTF-8. I did specify like this code:
iniSettings=new QSettings(filename,QSettings::IniFormat,this);//allocationg the reference to QSettings iniSettings->setIniCodec("UTF-8");//I want in this format , if set also I'm getting out in ANSI.
To ensure the QSetting is set to
UTF-8, I wrote all contents of the QSetting object to the another external file for testing purpose. checked it was ANSI and QSettings can't read backslashes and folder name with a number e.g:091-folder name
So how to read and convert to the UTF-8 encoding format using QSettings?
Can you provide an exact sample of code/data that shows that ?
6thC last edited by
QSettings settings( QSettings::IniFormat, QSettings::Scope::SystemScope, QCoreApplication::organizationName(), QCoreApplication::applicationName() ); settings.setIniCodec("UTF-8");
I do this. I can read anything (that's I've needed so far) from there.
However, big red flag wave, making QSettings writes my ini file hashes and semicolons get trashed. Line comments stripped. Basically, it's a QSettings file with an ini extension, not an ini file.
For reads it been fantastic - just beware if you are going to use QSettings for write ops... I just got bitten by this one too.
However, big red flag wave, making QSettings writes my ini file hashes and semicolons get trashed
As long as QSettings can read it back in I don't see a reason why this should be a problem.
You should read the note under the Format enum documenation which explains what happens with the
thippu last edited by
okay, now my requirement has been changed to reading ASCII encoding.