Making IDLE3 ignore non-BMP characters instead of throwing an exception?

Chris Angelico rosuav at gmail.com
Mon Oct 17 22:09:49 EDT 2016


On Tue, Oct 18, 2016 at 10:23 AM, eryk sun <eryksun at gmail.com> wrote:
> I don't know whether it causes problems elsewhere in Tk, but it has no
> problem passing along a UTF-16 string to Windows. For example, see the
> following with a breakpoint set on TextOut [1]:
>
>     >>> root = tkinter.Tk()
>     >>> w = tkinter.Label(root, text='test: \ud83d\udc4c')
>     >>> w.pack()

That's not a UTF-16 encoded byte string, though. It's a Unicode string
that contains two surrogates. So maybe the solution is to convert from
true Unicode strings into strings like the above - but if so, it
absolutely must not be done in any user-facing way. It should be an
implementation detail of Tkinter.

ChrisA



More information about the Python-list mailing list