text library
Text normalization, Roman Urdu spelling, Urdu digits, slugs, Urdu alphabetical order and bidirectional text.
Same as the pakdatakit/text entry point of the npm package.
Enums
- BidiDirection
- Direction for wrapBidi.
- SlugScript
- Which letters slugify keeps.
Functions
-
compareUrdu(
String a, String b) → int - Compares two strings in Urdu alphabetical order, for List.sort.
-
isRTL(
String text) → bool - Whether text reads right to left: its first letter is from a right-to-left script such as Urdu or Arabic. Digits, punctuation and spaces are skipped, as in the Unicode bidirectional algorithm's paragraph rule.
-
normalizeRomanUrdu(
String text) → String -
Normalizes informal Roman Urdu spellings to common forms (
kia→kya,nhi→nahi). -
normalizeText(
String text) → String - Normalizes general text: trims, collapses whitespace and applies Unicode NFC.
-
slugify(
String input, {SlugScript script = SlugScript.any}) → String -
Turns text into a URL slug: lower-case words joined by
-. -
toEnglishDigits(
String text) → String - Converts Urdu and Arabic-Indic digits to English digits (0–9).
-
toUrduDigits(
String text) → String - Converts English and Arabic-Indic digits to Urdu digits (۰–۹).
-
wrapBidi(
String text, [BidiDirection direction = BidiDirection.auto]) → String - Wraps text in Unicode directional isolates, so a name or number in one direction does not reorder the sentence around it (for example an English order number inside an Urdu message).