GNOME Bugzilla – Bug 57695
How should O_BINARY be handled for GIOChannel under the new API?
Last modified: 2011-02-18 15:47:43 UTC
see summary
From http://mail.gnome.org/archives/gtk-devel-list/2001-August/msg00080.html: My comment was: Let's: * Always specify O_BINARY on platforms where it matters * Keep in mind the future possibility of something like: g_io_channel_set_newline_format (channel, "\r\n"); This becomes most useful when we add encoding autodetection to glib - planned for a future version. Then we can add newline detection like that, and get the effect of something similar to Emacs's newline handling. Emacs, when it reads a file, autodetects the newline format as part of encoding detection, so you get an encoding like EUC-JP-DOS, manipulates newlines internally as '\n' then uses the same newline format when writing out the file. I think it is a good trait if the DOS and Unix versions of a program by default produce identical output files. And not specifying O_BINARY corrupts encodings such UTF-16. If we add the functionality to do read/write conversions of newlines, it should happen on the UTF-8 side of the conversion, and should be cross-platform.
I believe this was decided upon, and we'll consider the fact that Win32 doesn't specify O_BINARY here simply an implementation bug.
since 2001-09-21 Hans Breuer <hans@breuer.org> * glib/giowin32.c (g_io_channel_new_file) : always open in binary mode resolved.
Fixed by Hans Breuer on 2001-09-21.