Test files › Documents › utf8-no-bom.txt
UTF-8 text file without a BOM
UTF-8 without a byte-order mark. The correct modern default.
↓ Download utf8-no-bom.txt| Filename | utf8-no-bom.txt |
| Format | TXT |
| Size | 99 bytes (99 bytes) |
| MIME type | text/plain; charset=utf-8 |
| SHA-256 | 54838db0165f05296350688ed04e2304c616001ff8e1446a54ab24a10e8af99e |
What this file catchesReaders that guess Latin-1 and mangle the umlauts, CJK and emoji into mojibake.
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("utf8-no-bom.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: 0 CRLF, 2 LF, 0 bare CR
ends with a newline
longest line: 44 characters
invisible characters: none
Related guides and tools
Download & verify
curl -fsSL -o "utf8-no-bom.txt" "https://files.hexaqa.com/text/utf8-no-bom.txt"
curl -fsSL "https://files.hexaqa.com/text/utf8-no-bom.txt" | sha256sum
# expect: 54838db0165f05296350688ed04e2304c616001ff8e1446a54ab24a10e8af99e