[issue40863] bytes.decode changes/destroys line endings on windows

2020-06-04 Thread Matthias Naegler
New submission from Matthias Naegler : ``` # 0x0D, 13 = /r # 0x0A, 10 = /n print('test "\\r\\n"') print('-') b = bytes([0x41, 0x0D, 0x0A]) print("bytes: %s" % b) print("string: %s" % b.decode('utf8'), end='') #

[issue40863] bytes.decode changes/destroys line endings on windows

2020-06-04 Thread Matthias Naegler
Matthias Naegler added the comment: Thanks Steven for your fast response. > The best way to see what your string actually contains is the print the repr: You are right. bytes.decode is correct. Im not a python expert, so thanks for the note about "repr". With repr(...) everythi

[issue40863] bytes.decode changes/destroys line endings on windows

2020-06-04 Thread Matthias Naegler
Matthias Naegler added the comment: I forgot something important. Using open with 'ab' works. >>> ...above code... with open("./test_binary.txt", "ab") as myfile: ... myfile.write(s.encode('utf-8')) -- _