Reward
Invisible Unicode tags: detect, reveal and strip them before text reaches an AI
Four JavaScript one-liners to detect, reveal and strip invisible Unicode tag characters (U+E0000 to U+E007F) before text reaches a model, a flag-safe variant, and a checklist.
The Unicode Tags block (U+E0000 to U+E007F) holds an invisible copy of ASCII: tag code = ASCII code + 0xE0000, so U+E0041 is an "A" that fonts don't draw. An AI model reads code points, not pixels, so it reads that hidden text. Use these on anything you paste or pipe into a model: issues, emails, scraped pages, minified code.
1. Detect
const hasTags = text => /[\u{E0000}-\u{E007F}]/u.test(text);2. Reveal what's hidden
Subtract 0xE0000 (917504), the same step the fingerprinting script's own decoder used.
const reveal = text =>
[...text].map(c => {
const p = c.codePointAt(0);
return p >= 0xE0020 && p <= 0xE007E ? String.fromCodePoint(p - 0xE0000) : c;
}).join("");3. Strip before the model sees it
const clean = text => text.replace(/[\u{E0000}-\u{E007F}]/gu, "");4. Flag-safe version
The England, Scotland and Wales flags are a black flag (U+1F3F4) + tag letters (gbeng, gbsct, gbwls) + U+E007F CANCEL TAG. clean() turns them into plain black flags. This keeps only those three exact sequences and strips every other tag:
// group 1 = 🏴 + g b (eng | sct | wls) + CANCEL TAG; any other tag character is dropped
const cleanKeepFlags = text =>
text.replace(
/(\u{1F3F4}\u{E0067}\u{E0062}(?:\u{E0065}\u{E006E}\u{E0067}|\u{E0073}\u{E0063}\u{E0074}|\u{E0077}\u{E006C}\u{E0073})\u{E007F})|[\u{E0000}-\u{E007F}]/gu,
(m, flag) => flag ?? ""
);Don't just keep "any tags after a black flag": an attacker could hide a message behind one.
Checklist
0 / 4 done