Sujet : Re: Decoding bytes to text strings in Python 2
De : usenet202101 (at) *nospam* magic-cookie.co.ukNOSPAMPLEASE (Rayner Lucas)
Groupes : comp.lang.pythonDate : 22. Jun 2024, 14:13:28
Autres entêtes
Organisation : The Lumber Cartel (TINLC)
Message-ID : <MPG.40e0d04661dcc7cf9896e0@news.eternal-september.org>
References : 1 2 3
User-Agent : MicroPlanet-Gravity/3.0.4
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. I'm still not sure why it doesn't give an error on Windows and
instead either works (when UTF-8 encoding is specified) or converts the
out-of-range characters to ones it can display (when the encoding isn't
specified). But now I know what the root of the problem is, I can deal
with it appropriately (and my curiosity is at least partly satisfied).
This has given me a much better understanding of what I need to do in
order to migrate to Python 3 and add proper support for non-ASCII
characters, so I'm very grateful for your help!
Thanks,
Rayner