1

I'm reading a text file using Python3 even I have mentioned encoding but it retruns:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 96: invalid start byte [05/May/2018 03:35:45] "POST /app/ HTTP/1.1" 500 14383

It's not a duplicate but it's specific to byte 0x92.

Here's what I have tried:

txt = Path(text_path).read_text(encoding="utf-8")
Abdul Rehman
  • 5,326
  • 9
  • 77
  • 150

2 Answers2

7

Your textfile probably isn't encoded in utf-8. You might want to try a different encoding, e.g. encoding='cp1252'

CodeZero
  • 1,649
  • 11
  • 18
0

According to Exceen's answer on a related question, that's a "smart quote" in the Win-1252 encoding.

Nathan Mills
  • 2,243
  • 2
  • 9
  • 15