# Can I test line break types? e.g. line endings of type LF or LFCR?

Is it possible to test whether a "line feed" or "line feed + carriage return" were used to end lines in a tex file? I'd like to create a log message with this information.

The reasoning for this is to ensure that all of my files have the same line endings. I know that I could do this using a scripting language. I am just curious whether or not I can test for these characters in TeX? I know TeX sees them as equivalent e.g either situation would yield a single token when tokenizing. I guess this would need to happen before or during the tokenization phase. An example does not seem fitting here.

• The standard behavior of TeX Live implementations is to ascertain the line ending for a given file and act on consequence; it fails with LF-CR, usually, but it detects LF (Unix), CR+LF (Windows) and CR (legacy Mac OS). – egreg May 29 '17 at 14:12

No, or at least not from the TeX end (LuaTeX is different: can use Lua). Line-end normalisation happens very early, before any TeX code gets to see anything. As such, all you will ever get is characters of the value of `\endlinechar`, so they are always all the same (and so life is easy for the macro programmer).
This is all in the system-specific part of TeX hidden from the macro layer. On a mainframe with fixed length text fields there may be no line character and all lines are 80 (or 132 or whatever) characters wide, but the tex implementation on such machines will (or did when they existed) strip all trailing white space and make the input appear to be a stream of characters with a single `\endlinechar` marking lines (records).