Python Forum
'utf-8' codec can't decode byte 0xda in position 184: invalid continuation byte
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
'utf-8' codec can't decode byte 0xda in position 184: invalid continuation byte
#6
(Sep-07-2019, 02:46 AM)karkas Wrote: After opening as 'utf-8' for writing, the file works well with the subsequent converter.
Yes,remember utf-8 out and in,OS and local system can mess up stuff and choice wrong encoding.
newFile = open(fileName, 'w+', encoding='utf-8')
Quote:- C:\code would be a path to my code file?
No this is where i placed the file,you can choose whatever place you like.
Rember that python and pip should work from any folder same for all OS,for Windows look here
So a test like this should work no matter which folder on OS you are in.
E:\div_code\click
λ python -V
Python 3.7.3

E:\div_code\click
λ pip -V
pip 19.2.3 from c:\python37\lib\site-packages\pip (python 3.7)

Quote:- What does that λ mean?
That use cmder a much better shell than cmd/Poweshell.

Quote:- What is the difference between your first and second example? Just the same with different encoding depending on how you save the file?
When i use rb then i read file in binary(no encoding).
With Unicode still need to decode to a encoding.
>>> s = b'<i>[M\xc3\x9aSICA]</i>'
>>> s
b'<i>[M\xc3\x9aSICA]</i>'
>>> type(s)
<class 'bytes'>
>>> 
>>> t = s.decode()
>>> t
'<i>[MÚSICA]</i>'
>>> type(t)
<class 'str'>
Reply


Messages In This Thread
RE: 'utf-8' codec can't decode byte 0xda in position 184: invalid continuation byte - by snippsat - Sep-07-2019, 11:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Search for multiple unknown 3 (2) Byte combinations in a file. lastyle 7 1,382 Aug-14-2023, 02:28 AM
Last Post: deanhystad
Question UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 562: ord ctrldan 23 4,892 Apr-24-2023, 03:40 PM
Last Post: ctrldan
  UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd2 in position 16: invalid cont Melcu54 3 5,030 Mar-26-2023, 12:12 PM
Last Post: Gribouillis
  Decode string ? JohnnyCoffee 1 833 Jan-11-2023, 12:29 AM
Last Post: bowlofred
  extract only text strip byte array Pir8Radio 7 3,003 Nov-29-2022, 10:24 PM
Last Post: Pir8Radio
  [SOLVED] [Debian] UnicodeEncodeError: 'ascii' codec Winfried 1 1,037 Nov-16-2022, 11:41 AM
Last Post: Winfried
  sending byte in code? korenron 2 1,135 Oct-30-2022, 01:14 PM
Last Post: korenron
  UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 34: character Melcu54 7 19,072 Sep-26-2022, 10:09 AM
Last Post: Melcu54
  Byte Error when working with APIs Oshadha 2 1,022 Jul-05-2022, 05:23 AM
Last Post: deanhystad
  UnicodeEncodeError: 'ascii' codec can't encode character '\xfd' in position 14: ordin Armandito 6 2,745 Apr-29-2022, 12:36 PM
Last Post: Armandito

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020