question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1

See original GitHub issue

Hey guys I ran matlap2python on a matlab code but it seems like it gives me this exact error:

Traceback (most recent call last):
  File "/home/arshia/Desktop/matlab2python/matlab2python.py", line 49, in <module>
    main(sys.argv[1:])
  File "/home/arshia/Desktop/matlab2python/matlab2python.py", line 44, in main
    mparser.matlab2python(opts.filelist,opts)
  File "/home/arshia/Desktop/matlab2python/matlabparser/parser.py", line 433, in matlab2python
    matlab2python(f,opts)
  File "/home/arshia/Desktop/matlab2python/matlabparser/parser.py", line 437, in matlab2python
    MF=MatlabFile(filename=filename)
  File "/home/arshia/Desktop/matlab2python/matlabparser/parser.py", line 185, in __init__
    self.raw_lines=f.readlines()
  File "/usr/lib/python3.10/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa1 in position 242: invalid start byte

I will upload the matlab file to show what I mean exactly

matlab code.zip

The error seems to have migrated from smop cause smop had the same exact issue

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
AA1999commented, Jul 31, 2022

I hope so too! I’ll close the Issue until I see another of the same. Tried on the codes and both worked!

Tyvm

0reactions
ebranlardcommented, Jul 31, 2022

Sounds good, I’ve submitted a small correction. Encoding errors are always a bit of a pain. The alternative would be to detect the encoding using chardet, but hopefully this workaround is enough.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UnicodeDecodeError: 'utf8' codec can't decode byte 0x9c
Sometimes I get characters like this œ that cause the UnicodeDecodeError error. I need to be able to make the string UTF-8 with...
Read more >
UnicodeDecodeError utf-8 codec can t decode byte in position ...
While I importing the file it shows UnicodeDecodeError: "utf-8" codec can"t decode byte 0xa0 in position ... as pd a ...
Read more >
UnicodeDecodeError: 'utf-8' codec can't decode byte in position
The Python "UnicodeDecodeError: 'utf-8' codec can't decode byte in position: invalid continuation byte" occurs when we specify an incorrect encoding when ...
Read more >
Python3 Fix→ UnicodeDecodeError: 'utf-8' codec can't decode ...
Python3 Fix→ UnicodeDecodeError: 'utf-8' codec can't decode byte in position. INTRO. I am in the middle of importing some D&B Business data ...
Read more >
'utf8' codec can't decode byte 0xa5 in position 0: invalid start ...
Introduction · Often, while reading the input files, you might encounter an UnicodeDecodeError. · Thus, the error means that the byte 0xa05 at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found