Page 1 of 1

fsckin windows

Posted: Thu May 13, 2010 3:35 am
by M_D_K
so here's a little tale of why you should always open files as binary.

so I'm parsing text files for a little something I'm doing to fill time, and I start noticing the parsing catching in an infinite loop on windows, part of the parsing is looking ahead in the file for newlines(\n) so I'm not ending up with half a line in the buffer and having to deal with it.

the problem is how windows handles \n, when you open a file as just "r" (like fopen(file, "r");) windows expands \n to CR''LF on writes and compresses it to \n on reads (that's what bottom poster here says)

damn annoying!

I didn't have this problem on nix (linux, mac) because there's no expanion.