From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id E139E138239 for ; Wed, 13 Jan 2021 18:59:13 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F2B23E0932; Wed, 13 Jan 2021 18:59:08 +0000 (UTC) Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A76B5E0909 for ; Wed, 13 Jan 2021 18:59:08 +0000 (UTC) Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1kzlMJ-0001vZ-9p for gentoo-user@lists.gentoo.org; Wed, 13 Jan 2021 19:59:07 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: gentoo-user@lists.gentoo.org From: Grant Edwards Subject: [gentoo-user] Re: python3 question Date: Wed, 13 Jan 2021 18:59:03 -0000 (UTC) Message-ID: References: <3a417d99-a60e-8526-9df9-983894253885@web.de> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User-Agent: slrn/1.0.3 (Linux) X-Archives-Salt: 8ed254ea-1214-488e-8e8e-474962dd9d6b X-Archives-Hash: 6aa273297b7b6702ac9247dd3669fb3b On 2021-01-13, n952162 wrote: > Hello. In python3, how do you do this? Please explain what "this" is trying to accomplish, and we can tell you how to do it in Python3. Are you trying to convert from Unicode to Latin1 and back to Unicode? Python 3.8.6 (default, Jan 2 2021, 20:25:58) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> 'gebuchte Umsätze;'.encode('latin1').decode('latin1') 'gebuchte Umsätze;' > tgt = 'gebuchte Umsätze;' > > In python2, you could do this: > > tgt = unicode ('gebuchte Umsätze;'.decode ('latin1')) > > but that gives: > > SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xe4 in > position 12: invalid continuation byte > > In fact, any constant with ä in it will give you that.