What is a reliable way to detect which line break characters are used in a file?

Posted by Fabian Jakobs on Stack Overflow See other posts from Stack Overflow or by Fabian Jakobs
Published on 2010-04-23T09:11:44Z Indexed on 2010/04/23 9:13 UTC
Read the original article Hit count: 182

Filed under:
|
|
|

I'm reading text files but I don't know in advance the kind of line ending used in this file. I need to know whether it uses UNIX \n or windows style \r\n line endings.

What is a reliable and fast way to detect this?

© Stack Overflow or respective owner

Related posts about encoding

Related posts about Windows