-
Notifications
You must be signed in to change notification settings - Fork 0
normalizeUrduTehMarbuta
β οΈ Version Recommendation: Always install and use the latest version ofrtl-text-tools(npm install rtl-text-tools@latest). While this specific feature was introduced in an earlier version, the latest release includes crucial bug fixes, better edge-case handling, and improved legacy browser compatibility. Avoid pinning your project to an old version just to use this function.
Converts the Arabic Teh Marbuta (Ψ©) to the Urdu Heh Goal (Ϋ).
Like Persian, Urdu rarely uses the Arabic Teh Marbuta. When it appears in Urdu text, it is almost always a typo or the result of copy-pasting from an Arabic source (e.g., copying "Ω Ψ―Ψ±Ψ³Ψ©" instead of the correct Urdu "Ω Ψ―Ψ±Ψ³Ϋ"). Using Teh Marbuta in Urdu breaks standard Nastaliq font rendering and confuses Urdu spellcheckers. This function ensures your Urdu text is typographically correct.
normalizeUrduTehMarbuta(text: string): string| Name | Type | Description |
|---|---|---|
text |
string |
The text containing Arabic Teh Marbuta to normalize to Urdu Heh. |
-
string: Returns the text with all instances of Teh Marbuta (Ψ©) converted to the Urdu Heh Goal (Ϋ). Returns the original string unchanged if it is empty,null, or contains no Teh Marbuta.
import { normalizeUrduTehMarbuta } from 'rtl-text-tools';
// Arabic Teh Marbuta (Ψ©) -> Urdu Heh Goal (Ϋ)
normalizeUrduTehMarbuta("Ω
Ψ―Ψ±Ψ³Ψ©"); // "Ω
Ψ―Ψ±Ψ³Ϋ" (School)
normalizeUrduTehMarbuta("Ψ¬Ψ§Ω
ΨΉΨ©"); // "Ψ¬Ψ§Ω
ΨΉΫ" (University)
normalizeUrduTehMarbuta("ΨΪ©Ω
Ψ©"); // "ΨΪ©Ω
Ϋ" (Wisdom/Philosophy)
// Already correct Urdu text remains unchanged
normalizeUrduTehMarbuta("Ω
Ψ―Ψ±Ψ³Ϋ"); // "Ω
Ψ―Ψ±Ψ³Ϋ"When using beautiful Urdu Nastaliq fonts (like Jameel Noori Nastaleeq or Alvi Nastaleeq), the Arabic Teh Marbuta often renders awkwardly or disconnects from the preceding letters because the font expects the Urdu Heh Goal at the end of those specific word shapes.
import { normalizeUrduTehMarbuta, fixRTL } from 'rtl-text-tools';
const rawUrduText = "ΫΫ Ψ§ΫΪ© ΩΎΨ±Ψ§ΩΫ Ψ¬Ψ§Ω
ΨΉΨ© ΫΫ"; // Contains Arabic Ψ©
// Normalize the character, then apply standard RTL fixes
const cleanText = fixRTL(normalizeUrduTehMarbuta(rawUrduText), { lang: 'persian' });
// Note: Urdu shares digit/punctuation rules with Persian in this library
// Output: "ΫΫ Ψ§ΫΪ© ΩΎΨ±Ψ§ΩΫ Ψ¬Ψ§Ω
ΨΉΫ ΫΫ" (Now renders perfectly in Nastaliq fonts)This function specifically targets the Arabic Teh Marbuta and replaces it with the standard Urdu Heh Goal:
| Original Character | Name | Unicode | Replaced With | Urdu Name |
|---|---|---|---|---|
| Ψ© | Teh Marbuta | \u0629 |
Ϋ (\u06C1) |
Heh Goal |
-
Direct Replacement: The function uses a standard
String.prototype.replace()method with a global regular expression (/\u0629/g) to ensure every instance of the targeted character is replaced efficiently. - Typography Preservation: By converting this character, you ensure that the text will correctly connect and render according to Urdu typographic rules, which is absolutely crucial for professional UI design and accurate text processing in Pakistan and India.
-
IE11 Compatibility: It avoids modern string methods and the ES6
uregex flag, ensuring full compatibility with legacy browsers like IE11. -
Safe Execution: If the input is falsy (e.g.,
null,undefined, or""), it immediately returns the input without throwing an error.
-
v1.2.0: Added
normalizeUrduTehMarbuta()as part of the new Urdu language support to fix common Arabic character intrusions and improve Nastaliq font rendering.
π Home β’ π Getting Started β’ π API Reference β’ π Report Issue
Made with β€οΈ by Homayoun Mohammadi
If you find this project useful, please consider β starring the repo to show your support!
- π Home
- π Getting Started
- π§© API Overview
- π οΈ Framework Guides
- π‘ Use Cases
- π₯οΈ Browser Compatibility
- β FAQ & Troubleshooting
Homayoun Mohammadi
π GitHub β’ βοΈ Email
β Love this project? Star it on GitHub to show your support!