Hello,
I want to load a file with unicode:
The file:
Ðикифорова СÑндÑма Сохондо, ЧитинÑÐºÐ°Ñ Ð¾Ð±Ð».,
Ñон МоÑква, МоÑковÑÐºÐ°Ñ Ð¾Ð±Ð».,
Ðикифорова СÑндÑма Сохондо, ЧитинÑÐºÐ°Ñ Ð¾Ð±Ð».,
Ñон МоÑква, МоÑковÑÐºÐ°Ñ Ð¾Ð±Ð».,
To copy to clipboard, switch view to plain text mode
I made this function:
{
if (File.
open(QFile::ReadOnly)) {
if (unicode)
in.setCodec("UTF-16");
do
{
line = in.readLine();
if (!line.isEmpty())
list->append(line);
}
while (!line.isNull());
File.close();
}
}
void loadfromfile(QStringList *list, QString file, bool unicode)
{
QFile File(file);
if (File.open(QFile::ReadOnly))
{
QTextStream in(&File);
if (unicode)
in.setCodec("UTF-16");
QString line;
do
{
line = in.readLine();
if (!line.isEmpty())
list->append(line);
}
while (!line.isNull());
File.close();
}
}
To copy to clipboard, switch view to plain text mode
Yet when I load the file I am still not seeing the right characters:
loadfromfile(&list, filename, true);
foreach (s, list)
{
msg.setText(s);
msg.exec();
}
loadfromfile(&list, filename, true);
QString s;
foreach (s, list)
{
QMessageBox msg;
msg.setText(s);
msg.exec();
}
To copy to clipboard, switch view to plain text mode
Thanks for help.
Bookmarks