binary-stl-toASCII icon indicating copy to clipboard operation
binary-stl-toASCII copied to clipboard

couldn't convert binary stl file to ascii stl file

Open DezzardHD opened this issue 4 years ago • 6 comments

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

DezzardHD avatar Dec 18 '20 21:12 DezzardHD

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

FireWingHu avatar Dec 25 '20 16:12 FireWingHu

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!

DezzardHD avatar Dec 25 '20 16:12 DezzardHD

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. :)

FireWingHu avatar Dec 25 '20 16:12 FireWingHu

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

alwarnecke avatar Mar 25 '21 14:03 alwarnecke

im getting an xrange not defined error, someone please help

rishabh-shukla07 avatar Jun 19 '21 22:06 rishabh-shukla07

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

rishabh-shukla07 avatar Jun 19 '21 22:06 rishabh-shukla07