Hello,
I need to read a text file in binary mode (don't ask me why...). Is there any way I can get the end-of-line terminator for the current platform?
Hello,
I need to read a text file in binary mode (don't ask me why...). Is there any way I can get the end-of-line terminator for the current platform?
in my reckoning, \n would would on all platforms, its \n for linux and mac, \r\n for windows, but qt replaces that with \n
That's ok when you are opening the file in text mode. In non-text mode, readLine returns "hello\r\n" on windows and "hello\n" on linux, so the following code will work not work on Linux:
Qt Code:
if (line == "\r\n") processEmptyLine(line);To copy to clipboard, switch view to plain text mode
You are reading a file binary to process then each "line"?
It does not really help you to decide that you on windows have \r\n - still someone can copy/mail a unix file. What about split the buffer by \n into a QStringList and replace \r by ""?
Or use QString::simplified to check emptyness?
mattc (17th May 2009)
Bookmarks