Skip to content

REPL and input skip non-ascii characters of the input #7585

@aivarannamaa

Description

@aivarannamaa

A simple beginners' exercise of asking user's name (name = input("Enter your name: ")) can cause confusion when the name contains non-ascii chars, which are not echoed and don't make it to the interpreter.

The same goes to entering anything to the REPL. In order to rule out problems with serial terminal, I experimented with Pyserial against RPi Pico (MP 1.16):

import serial

s = serial.Serial("/dev/ttyACM0")
s.write("name = 'mõdu';print('Name:', name, len(name))\r\n".encode("utf-8"))
while True:
    print(s.readline().decode("utf-8"), end="")

The result was:

name = 'mdu';print('Name:', name, len(name))
Name: mdu 3

As you see, the letter "õ" didn't make it through.

Same problem occurs with ESP-32 and Unix ports. On the other hand -- CircuitPython 7.0.0a3 handles non-ascii input nicely.

The problem does not occur when reading input with sys.stdin.readline.

Metadata

Metadata

Assignees

No one assigned

    Labels

    unicodeBugs and enhancements related to Unicode/UTF-8 support.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions