Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #79253 > unrolled thread
| Started by | eryksun <eryksun@gmail.com> |
|---|---|
| First post | 2014-10-17 23:02 -0500 |
| Last post | 2014-10-17 23:02 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [Tutor] Convert Qstring to string in windows eryksun <eryksun@gmail.com> - 2014-10-17 23:02 -0500
| From | eryksun <eryksun@gmail.com> |
|---|---|
| Date | 2014-10-17 23:02 -0500 |
| Subject | Re: [Tutor] Convert Qstring to string in windows |
| Message-ID | <mailman.14953.1413605000.18130.python-list@python.org> |
On Thu, Oct 16, 2014 at 10:21 AM, C@rlos <cmferras@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.
Back to top | Article view | comp.lang.python
csiph-web