[Qt-interest] problem with accents
mierdatutis mi
mmm286 at gmail.com
Tue Aug 4 08:20:56 CEST 2009
Many thanks!
It works!
Now, I use qTextStream to read files instead of QByteArray.
I had not to use the line: in.setCodec("UTF-8");
Many thanks!
Best Regards,
2009/8/4 Andre Somers <andre at familiesomers.nl>
> mierdatutis mi wrote:
> > Yes, I know the file encoding is:
> >
> >
> > file: UTF-8 Unicode text
> >
> > 2009/8/4 Andre Somers <andre at familiesomers.nl
> > <mailto:andre at familiesomers.nl>>
> >
> > Hi,
> >
> > I would use QTextStream. It can do all the nasty coding/decoding
> > for you.
> > Do you know the encoding for your textfile? If not, find out. You
> > will need it to set the correct codec, no matter what way you end
> > up using.
> >
> >
> > > No, I don't use QtextStream. I do:
> > >
> > > while (!file.atEnd()) {
> > >
> > > QTableWidgetItem *item = new QTableWidgetItem;
> > >
> > > QByteArray line = file.readLine();
> > >
> > > item->setText(line);
> > >
> > > tabla->setItem(b,0,item);
> > >
> > > tabla->setRowHeight(b,20);
> > >
> > > b++;
> > >
> > > }
> > >
> >
> >
> So, change the above to using QTextStream:
>
> QTextStream in(&file);
> in.setCodec("UTF-8");
> while (!in.atEnd()) {
> QTableWidgetItem *item = new QTableWidgetItem;
> QString line = in.readLine();
> item->setText(line);
> tabla->setItem(b,0,item);
> ...
> }
>
> Note: code above is untested.Take it as pseudo-code ;-)
> Good luck!
>
> André
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090804/97adb5a6/attachment.html
More information about the Qt-interest-old
mailing list