What is the correct way of doing setIniCodec("UTF-8") to a QSetting object?
-
Hi,
I'm using windows and I would like to develop cross-platform.ini
file reading and editing using Qt.
My.ini
file 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? -
Hi,
Can you provide an exact sample of code/data that shows that ?
-
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.
-
@6thC said in What is the correct way of doing setIniCodec("UTF-8") to a QSetting object?:
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
.ini
file format.