Test files › Documents › line-endings-crlf.txt

Text file with CRLF line endings

20 lines terminated with Windows CRLF (\r\n).

↓ Download line-endings-crlf.txt
Filenameline-endings-crlf.txt
FormatTXT
Size1.0 KB (1,071 bytes)
MIME typetext/plain; charset=utf-8
SHA-256f1d13bf3e400ae9865148d88e8cbecbc553c5c78e76e833cf3b8e81d65280115
What this file catchesLine-based diffing, checksum comparison and CSV parsing that assumes LF. Pair with line-endings-lf.txt: the two must produce identical parsed rows.

Handle it in code

Each snippet below was run against this exact file with Python 3.14.4 and Node 24.15.0 when this page was built, and the output shown is what it printed.

Python

Read the bytes, not text mode, so the line endings survive to be counted. Invisible format characters (category Cf: zero-width spaces, direction overrides, the BOM) are the ones that make two identical-looking strings compare unequal.

import unicodedata

with open("line-endings-crlf.txt", "rb") as f:
    data = f.read()
crlf = data.count(b"\r\n")
lf, cr = data.count(b"\n") - crlf, data.count(b"\r") - crlf
print(f"line endings: {crlf} CRLF, {lf} LF, {cr} bare CR")
print("ends with a newline" if data.endswith(b"\n") else "no newline at the end of the file")
text = data.decode("utf-8")
print(f"longest line: {max(map(len, text.splitlines()), default=0):,} characters")
hidden = sorted({f"U+{ord(c):04X} {unicodedata.name(c, '?')}" for c in text if unicodedata.category(c) == "Cf"})
print("invisible characters:", ", ".join(hidden) if hidden else "none")

Run against this file, it prints: line endings: 20 CRLF, 0 LF, 0 bare CR ends with a newline longest line: 52 characters invisible characters: none

Related guides and tools

Sample TXT and encoding test filesCharacter encodingsVerify its SHA-256

Download & verify

curl -fsSL -o "line-endings-crlf.txt" "https://files.hexaqa.com/text/line-endings-crlf.txt"
curl -fsSL "https://files.hexaqa.com/text/line-endings-crlf.txt" | sha256sum # expect: f1d13bf3e400ae9865148d88e8cbecbc553c5c78e76e833cf3b8e81d65280115

More documents test files

truncated.pdfvalid-1page.pdfvalid-500pages.pdflatin1.txtline-endings-lf.txtno-trailing-newline.txtutf16be.txtutf16le.txt

← All Documents files