I read questions and answers for a quiz from a file in UTF-8 encoding but the answer can consists 1 byte symbols (English) and 2 byte symbols (Russian) in the same text:
"best car тайота"`
I need to write answer replaced with "*"
so it looks like "**** *** ******"
to help guess what answer is. For determining length I use
len(answer.decode('utf-8'))
But in the next hint when I want to show some symbols like "b*s* ca* *а*от*"
, I can access the 1 byte symbols via answer[index]
but I can't read 2 byte symbols this way, and that's why I get "b*s* ca*"
without 2 byte symbols.
Is there solution for this?