Skip to content

normalizeUrduTehMarbuta

Homayoun edited this page Jul 10, 2026 · 1 revision

Introduced in v1.2.0

⚠️ Version Recommendation: Always install and use the latest version of rtl-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.

πŸ“ Syntax

normalizeUrduTehMarbuta(text: string): string

Parameters

Name Type Description
text string The text containing Arabic Teh Marbuta to normalize to Urdu Heh.

Returns

  • 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.

πŸ’‘ Examples

Basic Usage

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("مدرسہ");   // "مدرسہ"

Fixing Font Rendering in Nastaliq

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)

🌍 Character Mapping

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

βš™οΈ Technical Details & Compatibility

  • 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 u regex 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.

πŸ“œ Version History

  • v1.2.0: Added normalizeUrduTehMarbuta() as part of the new Urdu language support to fix common Arabic character intrusions and improve Nastaliq font rendering.

πŸš€ rtl-text-tools

npm downloads

πŸ‘¨β€πŸ’» Created by

Homayoun Mohammadi
πŸ”— GitHub β€’ βœ‰οΈ Email

⭐ Love this project? Star it on GitHub to show your support!

Clone this wiki locally