My question is actually the question below:
python input UnicodeDecodeError:
in s = input("Enter a name:"), if the user enters a string in Unicode like علی and then press backspace and then enter (I mean using backspace to edit the input), it throws UnicodeDecodeError:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xdb in position 4: unexpected end of data
The accepted answer doesn't show any specific solution and relates it to the terminal and server encoding. I sat the LC_ALL=en_US.UTF-8 but it didn't solve the problem, the terminal also is in UTF-8. My PC OS is Ubuntu 20.04 and the server is ubuntu 16.04. The program is running on the server and I am connected to it via ssh.
it's the output of locale on the server:
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
My python version on the server is 3.7.10. I tested this on my laptop with python 3.8.5, and hadn't a problem. Then I installed python 3.8.8 on server using conda, the problem persists.
Also this problem isn't in the Python console, but when I call "python or python3.8 inp.py", when the input command is in a file named inp.py.
like علی andand paste in Python prompt (between a pair of quotes); you get'like \u200d\u200dعلی and'.