eerimoq / bincopy

Mangling of various file formats that conveys binary information (Motorola S-Record, Intel HEX, TI-TXT, Verilog VMEM, ELF and binary files).
MIT License
109 stars 38 forks source link

Bincopy Header does not allow non-ascii values #10

Closed frovirat closed 6 years ago

frovirat commented 6 years ago

Hello,

Due to our needs of our project, the headers could have binary values that represents Integer values over than ASCII such as 0x88, but the library does not allow it rasing an exception:

`bincopy.py in as_srec(self, number_of_data_bytes, address_length_bits) 684 685 if self._header: --> 686 encoded_header = self._header.encode('utf-8') 687 record = pack_srec('0', 0, len(encoded_header), encoded_header) 688 header.append(record)

UnicodeDecodeError: 'ascii' codec can't decode byte 0x88 in position 0: ordinal not in range(128) `

Could you modify the library to not enconde in UTF-8 and allow any kind of value to not limit only string headers?

Many thanks!! Ferran.

eerimoq commented 6 years ago

I made the header encoding and decoding optional in release 11.1.0. Use BinFile(header_encoding=None) to leave the header as an untouched bytes object. The default header encoding is still UTF-8.