1
votes

The empty box character shows up in a text, in place of a non-ascii character, so I need to replace that character in python, but I get an error:

SyntaxError: Non-ASCII character '\xef' in file pyautoGuiTiReg/main.py on line 197, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details.

I am not sure what encoding to use as this is a very weird symbol:

2
You can try using utf-8 since it encompasses huge number of characters. - Anshuman Tiwari

2 Answers

1
votes

As @AnshumanTiwari mentioned in the comments, utf-8 is the way to go when in doubt. By adding # -*- coding: utf-8 -*- to the top of the code, it ends up working perfectly.

1
votes

For replace it try this

ToBytes = str.encode('yourString', encoding='utf-8')     
ReplaceBytes = ToBytes.replace(b'\xef',b'').decode('utf-8')