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


Groups > comp.lang.python > #196321

Re: Decoding bytes to text strings in Python 2

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From MRAB <python@mrabarnett.plus.com>
Newsgroups comp.lang.python
Subject Re: Decoding bytes to text strings in Python 2
Date Mon, 24 Jun 2024 01:14:22 +0100
Lines 31
Message-ID <mailman.163.1719188251.2909.python-list@python.org> (permalink)
References <MPG.40dfb14de0110a999896df@news.eternal-september.org> <CAPTjJmpAYU2yxUhJd2mG4vkkK7JsViyF+7oat_Gw=AmfNi=A8g@mail.gmail.com> <mailman.159.1718991773.2909.python-list@python.org> <MPG.40e0d04661dcc7cf9896e0@news.eternal-september.org> <CAPTjJmrOfrz0RoYO9nhB+d+u7m0QLqYqfO2d4nSa4HG+LeLUdg@mail.gmail.com> <41260f11-89ae-433d-b44a-26c604b91356@mrabarnett.plus.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de N2gAtgBfcf5HYhWP17IuKgja8NO8XzitoaQ6n3FzSSMQ==
Cancel-Lock sha1:hUPm7Cg6Xwn3t3Fh+Xmz8B1TMXM= sha256:PSist8lJ4Zs5RQbne/gVmuJVojJxi1xJnT7rJKqL9Uo=
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
Authentication-Results mail.python.org; dkim=pass reason="2048-bit key; unprotected key" header.d=plus.com header.i=@plus.com header.b=ZNqKTz/I; dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'looks': 0.02; 'generated': 0.03; 'error:': 0.05; 'tkinter': 0.07; 'angelico': 0.09; 'characters,': 0.09; 'debian': 0.09; 'from:addr:python': 0.09; 'linux': 0.09; 'received:192.168.1.64': 0.09; 'subject:Python': 0.12; 'problem.': 0.15; '(because': 0.16; '*think*': 0.16; '00:30,': 0.16; '2024': 0.16; '3.8,': 0.16; '[snip]': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'received:plus.net': 0.16; 'solved': 0.16; 'using.': 0.16; 'wrote:': 0.16; 'problem': 0.16; 'python': 0.16; 'to:addr:python-list': 0.20; 'skip:_ 10': 0.22; 'install': 0.23; 'code': 0.23; 'idea': 0.24; 'python,': 0.25; 'seems': 0.26; 'jun': 0.26; 'chris': 0.28; 'header:User-Agent:1': 0.30; "doesn't": 0.32; 'python-list': 0.32; 'received:192.168.1': 0.32; 'but': 0.32; 'windows': 0.34; 'able': 0.34; 'header:In-Reply- To:1': 0.34; 'trying': 0.35; 'mon,': 0.36; 'system,': 0.36; "it's": 0.37; 'received:192.168': 0.37; 'way': 0.38; 'least': 0.39; 'handle': 0.39; 'rest': 0.39; 'still': 0.40; 'case.': 0.40; 'should': 0.40; 'above': 0.62; 'true': 0.63; 'email addr:gmail.com': 0.63; 'once': 0.63; 'range': 0.64; 'look': 0.65; 'back': 0.67; 'that,': 0.67; 'longer': 0.71; "you'll": 0.73; 'article': 0.73; 'operate': 0.75; 'bothered': 0.84; 'characters': 0.84; 'ultimately': 0.84; 'lucas': 0.91; 'oldest': 0.91; 'migrate': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019; t=1719188063; bh=9ZvvQHqg/9PYyfC/R45iJrBzTqrmt8OxF024n7eV3pI=; h=Date:Subject:To:References:From:In-Reply-To; b=ZNqKTz/IuZtv32bEzQnZxt7mSIWmaXMAobFxc5tcPyrpZV7g2rZJCpmlZgBrE+Zf5 FTbuS2hGS25YtK0CzcT9ZqH60SSA6zl5oc6E1S6XGrySIXyU8YNODmocsyUcwM6nYd 9J+Xx45EMyxxX4ytP2cUDl9plsvPHO0LVL5yb1D3bySoWYJDnGhIYqD/GCi+kovSTb TyVYlqBe2+/E6AhuyuLgk63T45txY/wM1I7MUr6HNma8cdSnLTcdzhZ3QcTw2uhZ+3 1g4vTy3jriK46/p5hesWvF+SNH7O+DXnHWayUjoVbMXdngimaiyvZqZYzzto7DONIS rFiMUZMz6eZ4w==
X-Clacks-Overhead "GNU Terry Pratchett"
X-CM-Score 0.00
X-CNFS-Analysis v=2.4 cv=MePPuI/f c=1 sm=1 tr=0 ts=6678ba5f a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=IkcTkHD0fZMA:10 a=8AHkEIZyAAAA:8 a=pGLkceISAAAA:8 a=XiE0LXHe_q3aitv2Jf0A:9 a=QEXdDO2ut3YA:10
X-AUTH mrabarnett@:2500
User-Agent Mozilla Thunderbird
Content-Language en-GB
In-Reply-To <CAPTjJmrOfrz0RoYO9nhB+d+u7m0QLqYqfO2d4nSa4HG+LeLUdg@mail.gmail.com>
X-CMAE-Envelope MS4xfBHfWWSodAw7+GHCjNkK9ZXxA5JsBPAMOCgBG4olhKxQxd0PJ0pyRZ5r7C5WzRHc7Eac9WzSaltIEy2wD/GFLTHBi/9HuFSaTdgDYr2YOCzc+5iUeJh6 p9HfewMOUEHHaVyIfblWZ/Yp6Sdxns+hhYmEdq3CecOwwpJ5/M2xQJErsUThe/i5a+/lGUtfXmHnoXirzN+B/pXqitVQlMWb6zE=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.39
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 <https://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>
X-Mailman-Original-Message-ID <41260f11-89ae-433d-b44a-26c604b91356@mrabarnett.plus.com>
X-Mailman-Original-References <MPG.40dfb14de0110a999896df@news.eternal-september.org> <CAPTjJmpAYU2yxUhJd2mG4vkkK7JsViyF+7oat_Gw=AmfNi=A8g@mail.gmail.com> <mailman.159.1718991773.2909.python-list@python.org> <MPG.40e0d04661dcc7cf9896e0@news.eternal-september.org> <CAPTjJmrOfrz0RoYO9nhB+d+u7m0QLqYqfO2d4nSa4HG+LeLUdg@mail.gmail.com>
Xref csiph.com comp.lang.python:196321

Show key headers only | View raw


On 2024-06-24 00:30, Chris Angelico via Python-list wrote:
> On Mon, 24 Jun 2024 at 08:20, Rayner Lucas via Python-list
> <python-list@python.org> wrote:
>>
>> In article <mailman.159.1718991773.2909.python-list@python.org>,
>> rosuav@gmail.com says...
>> >
>> > If you switch to a Linux system, it should work correctly, and you'll
>> > be able to migrate the rest of the way onto Python 3. Once you achieve
>> > that, you'll be able to operate on Windows or Linux equivalently,
>> > since Python 3 solved this problem. At least, I *think* it will; my
>> > current system has a Python 2 installed, but doesn't have tkinter
>> > (because I never bothered to install it), and it's no longer available
>> > from the upstream Debian repos, so I only tested it in the console.
>> > But the decoding certainly worked.
>>
>> Thank you for the idea of trying it on a Linux system. I did so, and my
>> example code generated the error:
>>
>> _tkinter.TclError: character U+1f40d is above the range (U+0000-U+FFFF)
>> allowed by Tcl
>>
>> So it looks like the problem is ultimately due to a limitation of
>> Tcl/Tk.
> Yep, that seems to be the case. Not sure if that's still true on a
> more recent Python, but it does look like you won't get astral
> characters in tkinter on the one you're using.
> 
[snip]
Tkinter in recent versions of Python can handle astral characters, at 
least back to Python 3.8, the oldest I have on my Windows PC.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Decoding bytes to text strings in Python 2 Rayner Lucas <usenet202101@magic-cookie.co.ukNOSPAMPLEASE> - 2024-06-21 16:49 +0100
  Re: Decoding bytes to text strings in Python 2 Chris Angelico <rosuav@gmail.com> - 2024-06-22 03:42 +1000
    Re: Decoding bytes to text strings in Python 2 Rayner Lucas <usenet202101@magic-cookie.co.ukNOSPAMPLEASE> - 2024-06-22 13:13 +0100
      Re: Decoding bytes to text strings in Python 2 (Posting On Python-List Prohibited) Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-22 23:19 +0000
      Re: Decoding bytes to text strings in Python 2 Chris Angelico <rosuav@gmail.com> - 2024-06-24 09:30 +1000
      Re: Decoding bytes to text strings in Python 2 MRAB <python@mrabarnett.plus.com> - 2024-06-24 01:14 +0100
      Re: Decoding bytes to text strings in Python 2 Chris Angelico <rosuav@gmail.com> - 2024-06-24 11:43 +1000
      Tkinter and astral characters (was: Decoding bytes to text strings in Python 2) "Peter J. Holzer" <hjp-python@hjp.at> - 2024-06-24 13:03 +0200
  Re: Decoding bytes to text strings in Python 2 Rayner Lucas <usenet202101@magic-cookie.co.ukNOSPAMPLEASE> - 2024-06-22 13:26 +0100

csiph-web