jiesutd / YEDDA

YEDDA: A Lightweight Collaborative Text Span Annotation Tool. Code for ACL 2018 Best Demo Paper Nomination.
Apache License 2.0
1.02k stars 297 forks source link

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc1 in position 14: invalid start byte #44

Open FXLP opened 3 years ago

FXLP commented 3 years ago

when I add a new txt, it was wrong like this:

Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\86152\AppData\Local\Programs\Python\Python39\lib\tkinter__init.py", line 1885, in call__ return self.func(*args) File "C:\Users\86152\Desktop\YEDDA-py3\YEDDA.py", line 251, in onOpen text = self.readFile(fl) File "C:\Users\86152\Desktop\YEDDA-py3\YEDDA.py", line 262, in readFile text = f.read() File "C:\Users\86152\AppData\Local\Programs\Python\Python39\lib\codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc1 in position 14: invalid start byte

how can I solve the problem?

feiba54 commented 3 years ago

Maybe change text = f.read() into text = f.read(encoding = "GBK") or the corresponding encoding for your txt?