I have a function that returns a string. The string contains carriage returns and newlines (0x0D, 0x0A). However when I write to a file it contains only the new line feeds. Is there a way to get the output to include the carriage return and the newline?
JavaScript
x
5
1
msg = function(arg1, arg2, arg3)
2
f = open('/tmp/output', 'w')
3
f.write(msg)
4
f.close()
5
Advertisement
Answer
If you want to write bytes then you should open the file in binary mode.
JavaScript
1
2
1
f = open('/tmp/output', 'wb')
2