In a loop, I add input function and type Persian (like Arabic) characters. It works well, but sometimes I get errors like this:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xdb in position 6: invalid continuation byte
I Use Debian and Run my code in xfce terminal and the default encode is utf-8.
I tried this instead of input():
sys.stdin.readline()
But, that error occurs. Is it a xfce Terminal Problem or a Python problem? Why does it occur sometimes? After get this error, I run my code again and type exactly same string, and this time, everything works well.
Can I handle it by this:
while True:
try:
i = input()
break
except:
pass
Or should I do something else?
Extra information: My inputs are Persian number like '۰ ۱ ۴' and English (for my purpose, it not important). Sometimes I amend a text that is a book name like 'دیوان حافظ ۳ جلدی' In my XFCE Terminal default encode is utf-8. Is it possible when I get this error, Terminal used another encode?
I guess this is a XFCE terminal bug. I installed terminator and used it for a while. That error never occurred, But I'm not sure.