Skip to main content
toPersianChars replaces Arabic letterforms that look identical to Persian with the Persian code points, plus normalizes Arabic diacritics. Content inside {{...}} template segments is preserved verbatim.

Function

What it normalizes

Plus diacritics (ً ٌ ٍ َ ُ ِ ّ ْ) and Arabic punctuation (٫, ٬) — see src/modules/toPersianChars/index.ts for the full table.

What it does NOT do

  • No Latin → Persian. It does not convert yی, kک, or %٪.
  • No digit conversion. It does not touch ٠١٢ (Arabic-Indic) or 123 (Latin). Use the Digits module for that.
  • No whitespace / ZWNJ normalization. Use the Half-Space module for ZWNJ insertion.
For a full normalization pipeline:

Template preservation

Anything between {{ and }} is preserved verbatim:
The implementation extracts {{...}} segments into placeholders, transforms the rest, then restores the segments.

Pitfalls

  • Latin and digits are untouched — older docs claim Latin → Persian conversion. They are wrong.
  • Running on text with intentional Arabic content will silently change it. Wrap Arabic sections in {{...}} or skip the call.
  • For very large documents, each replacement rule runs O(n). Consider per-field application rather than whole-document.

Source

src/modules/toPersianChars/index.ts · Tests: test/toPersianChars.spec.ts