Use binary mode for file output
File output does not work properly on Windows, at least under MinGW. This is because ao_open_file
does not pass the b
flag to fopen
, and so the file is opened in text mode. A carriage return character is then inserted into the output file before each line feed character.
As noted here, applications can request binary mode by using the b
flag:
https://cygwin.com/faq.html#faq.api.cr-lf
In POSIX operating systems, the b
flag is ignored:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html
Therefore, it should be safe to add it here.