PromptShield logo PromptShield
API DocsFunctions

scanHomoglyphs()

scanHomoglyphs(text, options?, context?): ThreatReport[]

Defined in: homoglyph.ts:61

Homoglyph detector.

Detects visually deceptive words that mix characters from different Unicode scripts — a common technique used in spoofing attacks.

Example:

"pаypal" (Cyrillic "а" inside Latin word) "admіn" (Cyrillic "і")

These words appear normal to humans but differ at the code-point level.

Detection model:

  • Scan text for "word spans"
  • Check script composition per word
  • Emit ONE threat per suspicious word

Span semantics: offendingText = entire word

Requires Unicode property escape support (Node 18+).

Rule: PSU101 — Mixed-script homoglyph detection

Parameters

text

string

Raw text to scan

options?

ScanOptions = {}

Scanner configuration

context?

ScanContext = {}

Location context

Returns

ThreatReport[]

On this page