problem about line-endings-Collection of common programming errors
Matt
php line-endings newline
I need to compare two text files in php. One file is user uploaded, and the other is supplied by the server, running on windows. This works fine when the file is submitted from another windows computer, but from a linux computer the files come out different, I am assuming this is because of different line endings. Is there an easy way to compare windows text files to linux text files?Currently this is my code;$text1 = file_get_contents($file1); $text2 = file_get_contents($file2); if (strcmp($co
Daniel Leung
c windows line-endings newline
On Windows this#include <stdio.h>int main() { putc(‘A’,stdout);putc(‘\r’,stdout); putc(‘\n’,stdout); }outputsA<CR><CR><LF>How to write just LF char to stdout without automatic conversion to CR LF? I need it to make simple socket stream reader to stdout. I’ve tried bcc32 from CodeGear, mingw, tinycc all yield same result, changing putc to putchar, fputc, fwrite doesn’t help either.
Perception
java line-endings
As suggested by this answer:You can callSystem.setProperty(“line.separator”, “\r\n”);in order to set the system property inside your code.it is quite easy to make a Java program output the desired line endings. However, I see no reason why one shouldn’t be able to change that environment variable, say, as a compiler setting?
Web site is in building