Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #79253

Re: [Tutor] Convert Qstring to string in windows

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <eryksun@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '16,': 0.03; 'subject:: [': 0.04; 'utf-8': 0.07; 'string': 0.09; 'bytes,': 0.09; 'subject:string': 0.09; 'way:': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'gui': 0.12; 'windows': 0.15; 'in-memory': 0.16; 'paths.': 0.16; 'subject:Convert': 0.16; 'subject:Tutor': 0.16; 'subject:windows': 0.16; 'wrote:': 0.18; 'skip:p 40': 0.19; 'thu,': 0.19; 'subject:] ': 0.20; '>>>': 0.22; 'preferred': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**1': 0.23; 'byte': 0.24; 'least': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'character': 0.29; 'message- id:@mail.gmail.com': 0.30; 'correctly.': 0.31; 'text': 0.33; 'linux': 0.33; 'cc:no real name:2**1': 0.33; 'received:google.com': 0.35; 'controls': 0.36; 'files': 0.38; 'skip:u 10': 0.60; '8bit%:100': 0.72; '8bit%:77': 0.84; 'resistance': 0.84; '850': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=J5rUeUrRDCWqpiFOsirgCcYEjHPzoBJ0t/HP6/X7nYA=; b=lBA+wc2MxPJ73ZRUR9uImfjlSMxcY7mBkJDdN3RsMk5HGoT9R+CIHePkG1xQkQWQPP K0xOP2F16Cl0KfJJGimp7NhBRZE8kiGFXqCBRRnDWKT2LTJczEKTZbFMvAuqfEjcoT+K 61dF1SPKqC41T7jlDTVKZu2UJdyuRqY3XNZCh1APyaPRG5UEGwuQV/3WygPg9MGTy1il z90MNcmnu+UAcbEC9nDxVgGyZ3Kh+mH6zIp41M7+Ag7KSPChgU4xvE0DGqw0Ej1MNGuu JXohJcINXTBS8BhS18Q/Lv9wTV6QLNI8kiJPuXgehM8PN7kfvv8dS4HVpEoCOYvFjZX7 XKXQ==
X-Received by 10.140.39.134 with SMTP id v6mr5905107qgv.19.1413604996915; Fri, 17 Oct 2014 21:03:16 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <969535236.13984943.1413472898089.JavaMail.zimbra@estudiantes.uci.cu>
References <1549164247.13980291.1413472329833.JavaMail.zimbra@estudiantes.uci.cu> <969535236.13984943.1413472898089.JavaMail.zimbra@estudiantes.uci.cu>
From eryksun <eryksun@gmail.com>
Date Fri, 17 Oct 2014 23:02:36 -0500
Subject Re: [Tutor] Convert Qstring to string in windows
To "C@rlos" <cmferras@estudiantes.uci.cu>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org, tutor@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.14953.1413605000.18130.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1413605000 news.xs4all.nl 2877 [2001:888:2000:d::a6]:54373
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:79253

Show key headers only | View raw


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 comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: [Tutor] Convert Qstring to string in windows eryksun <eryksun@gmail.com> - 2014-10-17 23:02 -0500

csiph-web