Thanks...

I have done exactly that, how can I get a list of valid "codec" names to put in 
a combo box, so that the user can select one?

What I do to set the codec, is the following
        QTextCodec * codec = QTextCodec::codecForName( codecName );
        if ( codec )
            QTextCodec::setCodecForLocale( codec );
Scott

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of 
Thiago Macieira
Sent: Wednesday, April 10, 2013 5:55 PM
To: [email protected]
Subject: Re: [Interest] QPlainTextEdit and a Unicode file

On quarta-feira, 10 de abril de 2013 23.59.05, Scott Aron Bloom wrote:
> The Loading process is as follows:

#define QT_NO_CAST_FROM_ASCII

>             QByteArray contents = fi.readAll();
>             fi.close();
>             setPlainText( contents );

The last line here will error out saying that you're converting from QByteArray 
to QString.

Whenever you do that, you need to tell what codec to use.

If your next question is "how do I detect the encoding of a file", the answer 
is that you don't. Detecting the encoding is a guessing scenario. Certain libs 
have a good guess ratio, but it's still a guess.

If you must *know* the encoding, you should add the drop-down combobox to your 
open dialog, or you have to add a menu to change the encoding (and reload the 
file).
--
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to