Sergex
4th September 2013, 10:49
Hello,
I have an application that gets a list of names from a text file and store those names in a QStringList. Afterwards, I use that list to access certain items of a QHash that have the names stored in my QStringList as their keys. The problem I am having is that some of the names might have special characters such as é, à , ù, etc.
So when this is the case I realized that when a name such as "Jérémy" for example, this name gets stored in the QStringList as "J?r?my" so when I want to access the item which has as key "Jérémy", my QHash it doesn't find the item.
How can I make the QStringList store the names with special characters correctly ? When reading from the text file to the QStringList I am doing:
QFile file(name);
file.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream in(&file);
in.setCodec("UTF-8");
// then in a loop while not at the end of the text file..
QString line = in.readLine();
myStrList.append(line);
Appreciate any help! Thanks.
I have an application that gets a list of names from a text file and store those names in a QStringList. Afterwards, I use that list to access certain items of a QHash that have the names stored in my QStringList as their keys. The problem I am having is that some of the names might have special characters such as é, à , ù, etc.
So when this is the case I realized that when a name such as "Jérémy" for example, this name gets stored in the QStringList as "J?r?my" so when I want to access the item which has as key "Jérémy", my QHash it doesn't find the item.
How can I make the QStringList store the names with special characters correctly ? When reading from the text file to the QStringList I am doing:
QFile file(name);
file.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream in(&file);
in.setCodec("UTF-8");
// then in a loop while not at the end of the text file..
QString line = in.readLine();
myStrList.append(line);
Appreciate any help! Thanks.