-
Notifications
You must be signed in to change notification settings - Fork 371
Description
When trying to open a file, an encoding error occurs.
Traceback (most recent call last):
File "C:\Bricklayers\bricklayers.py", line 139, in
process_gcode(
~~~~~~~~~~~~~^
input_file=args.input_file,
^^^^^^^^^^^^^^^^^^^^^^^^^^^
layer_height=args.layerHeight,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
extrusion_multiplier=args.extrusionMultiplier,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "C:\Bricklayers\bricklayers.py", line 46, in process_gcode
lines = infile.readlines()
File "C:\Program Files\Python313\Lib\encodings\cp1251.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 739: character maps to
Solution: explicitly specify the encoding when opening the file.
with open(input_file, 'r', encoding='utf-8') as infile: