[Interest] Converting std::string.c_str() code to use QString methods

Thiago Macieira thiago.macieira at intel.com
Sat Aug 31 18:41:32 CEST 2013


On sábado, 31 de agosto de 2013 16:31:19, Syam Krishnan wrote:
> > Even “simple English” may contain characters not encodable in Latin 1…
> > 
> > As I've just proven
> 
> Oh.. by 'simple English', I meant basic ASCII.. Anyway, if the original 
> string contained anything other than ASCII printable characters, 
> toAscii(), toLatin1() etc can't really do anything, right?

Well, if you meant "if the original string was ASCII, can I convert back to 
ASCII", the answer is "yes" :-)

If the string contains non-ASCII characters:

toLatin1() - if the characters are in Latin 1, then the string is safe; if 
not, they will be replaced by a question mark

toAscii() - in Qt 5, the behaviour is undefined; in Qt 4, it depends on the 
codec set by setCodecForCStrings. The default codec is Latin 1.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130831/323abd93/attachment.sig>


More information about the Interest mailing list