Test files › Documents › zero-width-and-rtl.txt
Text with zero-width and RTL characters
Text containing zero-width spaces, zero-width joiners, and bidirectional override characters (U+202E).
↓ Download zero-width-and-rtl.txt| Filename | zero-width-and-rtl.txt |
| Format | TXT |
| Size | 94 bytes (94 bytes) |
| MIME type | text/plain; charset=utf-8 |
| SHA-256 | 655072c13266ced43394f7f4f66a7e59d5047ae53e2f17447b2a9bafe8a83e30 |
What this file catchesSearch and dedupe logic that treats visually identical strings as different, and UI that renders text in an order the underlying bytes do not match (Trojan Source class of bug).
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("zero-width-and-rtl.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, 4 LF, 0 bare CR
ends with a newline
longest line: 35 characters
invisible characters: U+200B ZERO WIDTH SPACE, U+200D ZERO WIDTH JOINER, U+202C POP DIRECTIONAL FORMATTING, U+202E RIGHT-TO-LEFT OVERRIDE
Related guides and tools
Download & verify
curl -fsSL -o "zero-width-and-rtl.txt" "https://files.hexaqa.com/text/zero-width-and-rtl.txt"
curl -fsSL "https://files.hexaqa.com/text/zero-width-and-rtl.txt" | sha256sum
# expect: 655072c13266ced43394f7f4f66a7e59d5047ae53e2f17447b2a9bafe8a83e30