On sexta-feira, 30 de agosto de 2013 19:47:48, Syam wrote:
> On 31-Aug-2013 6:28 AM, "Thiago Macieira" <thiago.macie...@intel.com> wrote:
> > On sexta-feira, 30 de agosto de 2013 19:17:58, Scott Aron Bloom wrote:
> > > I use toUtf8()... Though it wouldn't surprise me if Thiago scolds me
> > > for it
> >
> > If you're on Unix, that's fine. It's fine because if your Unix system
> > uses a
> > locale different from UTF-8, you *really* should be scolded :-)
> 
> On Linux, whenever I need a const char* from a QString, I always do
> toLatin1().constData().
> 
> Earlier I used toAscii(), but then some discussion on Qt5 suggested that
> toLatin1() is more appropriate.

toAscii() and toLatin1() are most often the same. Except when they aren't -- 
that's when someone called setCodecForCStrings. And then toAscii() is no 
longer doing ASCII, it's doing something potentially incompatible with ASCII.

That's why this function is deprecated in Qt 5. In Qt 5, it's documented to do 
US-ASCII only and it has undefined behaviour if the QString contains characters 
not encodable in US-ASCII.

> Am I right here? Of course, the assumption is that the original QString is
> simple English text.

Even “simple English” may contain characters not encodable in Latin 1…

As I've just proven :-)

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to