micropython icon indicating copy to clipboard operation
micropython copied to clipboard

Interactive REPL does not support unicode/utf8

Open peterhinch opened this issue 8 years ago • 5 comments

Copy the following and paste it at the REPL:

z = 'ÇØĚ'

In paste mode it works, but not at the REPL prompt where the string contents disappears.

peterhinch avatar Jan 13 '17 17:01 peterhinch

The interactive REPL does not support unicode/utf8. It requires some effort to implement because one needs to support backspace/delete of utf8-encoded chars, as well as moving left/right across them.

dpgeorge avatar Jan 16 '17 03:01 dpgeorge

Fair enough - but might this cause problems for non-English speakers? Is simply swallowing the characters the best way to deal with it? I encountered this when debugging a program. A long string contained a few instances of chr(176) - the degree symbol. The REPL let me paste the string while silently modifying it. It took me a while to spot that it was the REPL rather than my code that was the culprit.

peterhinch avatar Jan 16 '17 08:01 peterhinch

but might this cause problems for non-English speakers?

Yes. We support utf8 in strings so should support it at the REPL as well. The simplest thing to do is just allow through all bytes (greater than 126 in value) to the REPL line. Beyond that, supporting left/right cursor motion, and deletion, is more tricky.

dpgeorge avatar Jan 17 '17 06:01 dpgeorge

Is there any plan to implement this unicode support for REPL?

As far as i know, it will be very helpful to chinese users.

laowu2019 avatar Mar 04 '20 01:03 laowu2019

This function is needed very much, which can make us use repl more amicably. I hope it can be put on the agenda as soon as possible. Thank the team for their efforts.

Sdator avatar May 20 '23 14:05 Sdator

Tested on MicroPython 1.24 with Unix port. Issue still present - the characters do not appear.

jonnor avatar Sep 29 '24 09:09 jonnor