[Tutor] Convert Qstring to string in windows
eryksun
eryksun at gmail.com
Sat Oct 18 00:02:36 EDT 2014
More information about the Python-list mailing list
Sat Oct 18 00:02:36 EDT 2014
- Previous message (by thread): Convert Qstring to string in windows
- Next message (by thread): [Tutor] Convert Qstring to string in windows
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Oct 16, 2014 at 10:21 AM, C at rlos <cmferras at estudiantes.uci.cu> wrote: > in linux i do for this way: > pythonstringtext=qstringtext.text().toUtf8.data() > and it return a python string correctly. pythonstringtext is a byte string that has to be decoded as UTF-8. Here's the 'mojibake' result when it gets decoded as UTF-16LE or Windows codepages 850 and 1252: >>> s = u'áéíóú' >>> b = s.encode('utf-8') >>> print b.decode('utf-16le') ꇃ꧃귃돃뫃 >>> print b.decode('850') ├í├®├¡├│├║ >>> print b.decode('1252') áéÃóú The native character size in the Windows kernel is 2 bytes, so UTF-16 is the path of least resistance for in-memory strings used with GUI controls and file/registry paths. UTF-8 is preferred for text data in files and network communication.
- Previous message (by thread): Convert Qstring to string in windows
- Next message (by thread): [Tutor] Convert Qstring to string in windows
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list