Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

couldn't convert binary stl file to ascii stl file #1

Open
DezzardHD opened this issue Dec 18, 2020 · 6 comments
Open

couldn't convert binary stl file to ascii stl file #1

DezzardHD opened this issue Dec 18, 2020 · 6 comments

Comments

@DezzardHD
Copy link

DezzardHD commented Dec 18, 2020

Hey,
I tried to convert a binary stl file to ascii stl file, but I received an error message stating, that in some line it wasn't possible to resolve the binary part to an ascii symbol.
If you want to look into that problem, I can send you the stl file I am talking about.

The terminal output:
File "C:\Users\myname\Documents\Eclipse Workspace\STL_Converter\binary-stl-toASCII\BinaryToASCII.py", line 7, in
data = infile.read()
File "C:\Program Files\Python39\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 335: character maps to

C:\Users\myname\Documents\Eclipse Workspace\STL_Converter\binary-stl-toASCII>

Best regards
Dezzard

@FireWingHu
Copy link

FireWingHu commented Dec 25, 2020

Hi!
I have the same problem:

Traceback (most recent call last):
File "C:\D\arduino\projects\cnc\binary-stl-toASCII-6f4e46c21ad33b19d0b99a6e1b40003e45ac8f0b\BinaryToASCII.py", line 7, in
data = infile.read()
File "C:\Users\FireWing\AppData\Local\Programs\Python\Python39\lib\encodings\cp1250.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x88 in position 472: character maps to undefined

@DezzardHD
Copy link
Author

Hi!
I have the same problem:

Traceback (most recent call last):
File "C:\D\arduino\projects\cnc\binary-stl-toASCII-6f4e46c21ad33b19d0b99a6e1b40003e45ac8f0b\BinaryToASCII.py", line 7, in
data = infile.read()
File "C:\Users\FireWing\AppData\Local\Programs\Python\Python39\lib\encodings\cp1250.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x88 in position 472: character maps to undefined

Hi!
I wasn't able to fix the code. Sorry.
Have a nice day!

@FireWingHu
Copy link

Ok, no problem, modifying this line:

infile = open('binary.stl') #import file

to this:

infile = open('binary.stl', encoding="utf8") #import file

has solved the problem for me. :)

@alwarnecke
Copy link

If @FireWingHu's method did not work for you, you can also try explicitly opening the file as read-only and binary, as follows:

infile = open('binary.stl', 'rb') #import file

@rishabh-shukla07
Copy link

im getting an xrange not defined error, someone please help

@rishabh-shukla07
Copy link

If @FireWingHu's method did not work for you, you can also try explicitly opening the file as read-only and binary, as follows:

infile = open('binary.stl', 'rb') #import file

I did this and it stopped the other errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants