Gentoo Archives: gentoo-user

From: Grant Edwards <grant.b.edwards@×××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] Re: python3 question
Date: Wed, 13 Jan 2021 18:59:13
Message-Id: rtnftm$j19$1@ciao.gmane.io
In Reply to: [gentoo-user] python3 question by n952162
1 On 2021-01-13, n952162 <n952162@×××.de> wrote:
2
3 > Hello. In python3, how do you do this?
4
5 Please explain what "this" is trying to accomplish, and we can tell
6 you how to do it in Python3. Are you trying to convert from Unicode to
7 Latin1 and back to Unicode?
8
9 Python 3.8.6 (default, Jan 2 2021, 20:25:58)
10 [GCC 9.3.0] on linux
11 Type "help", "copyright", "credits" or "license" for more information.
12 >>> 'gebuchte Umsätze;'.encode('latin1').decode('latin1')
13 'gebuchte Umsätze;'
14
15
16 > tgt = 'gebuchte Umsätze;'
17 >
18 > In python2, you could do this:
19 >
20 > tgt = unicode ('gebuchte Umsätze;'.decode ('latin1'))
21 >
22 > but that gives:
23 >
24 > SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xe4 in
25 > position 12: invalid continuation byte
26 >
27 > In fact, any constant with ä in it will give you that.

Replies

Subject Author
Re: [gentoo-user] Re: python3 question n952162 <n952162@×××.de>