[Qt-interest] How to detect Text codec
Harri Pasanen
grego at mpaja.com
Mon May 16 16:29:01 CEST 2011
If it is raw text, you can only guess.
Applying statistics you can do an educated guess, but that seldom works very
well.
Usually encoding is explicit in the file, for instance see
http://en.wikipedia.org/wiki/Byte_order_mark
-Harri
Monday, May 16, 2011 02:20 pm
NoRulez writes:
> I want to read a file from the filesystem, for that I use
> QIODevice::readAll();
>
> Now I want to know the codec (ISO-8859-1, UTF-8, ...)
>
> Because if it is UTF8 than I can use QString::fromUtf8(), but if it is
> ISO-8859-1 for example then I can't use QString::fromUtf8() because it
> produce garbage.
>
> @Rajiv: BOM isn't required to use UTF-8
>
> Best Regards
>
> Am 16.05.2011 um 13:23 schrieb Atlant Schmidt <aschmidt at dekaresearch.com>:
> > NoRulez:
> >
> > I think you need to give us a bit more context
> > for your question.
> >
> > Atlant
> >
> > -----Original Message-----
> > From: qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com
> > [mailto:qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com] On
> > Behalf Of NoRulez Sent: Monday, May 16, 2011 07:07
> > To: Qt Interest MailingList
> > Subject: [Qt-interest] How to detect Text codec
> >
> > Hi,
> >
> > can anybody give me a hint to detect the text codec used in a text file?
> >
> > Thanks in advance
> >
> > Best Regards
> > NoRulez
> > _______________________________________________
> > Qt-interest mailing list
> > Qt-interest at qt.nokia.com
> > http://lists.qt.nokia.com/mailman/listinfo/qt-interest
> >
> > This e-mail and the information, including any attachments, it contains
> > are intended to be a confidential communication only to the person or
> > entity to whom it is addressed and may contain information that is
> > privileged. If the reader of this message is not the intended recipient,
> > you are hereby notified that any dissemination, distribution or copying
> > of this communication is strictly prohibited. If you have received this
> > communication in error, please immediately notify the sender and destroy
> > the original message.
> >
> > Thank you.
> >
> > Please consider the environment before printing this email.
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list