BlogBooks & scholarship7 min read
Urdu OCR to Word: fix Arabic letters, broken search and fonts
Urdu uses its own Unicode letters for kaf, heh and yeh. If OCR writes Arabic ك, ه or ي instead of Urdu ک, ہ or ی, the file looks right but search fails. Search for the Arabic forms, replace them in the Urdu passages, and deliver in a font the recipient has.
You have a scanned Urdu book, a printed edition with Urdu commentary, or a page of Urdu correspondence, and OCR has turned it into a Word file. The text flows right to left and reads correctly on screen. Then someone searches for a word they can see and Word finds nothing, a sort puts entries in the wrong order, or the recipient opens the file and every line has switched into a different-looking font.
The usual cause is that Urdu and Arabic share a script but not all of their letters. Several Urdu letters have their own Unicode characters that look almost or exactly like the Arabic ones in many fonts. A file can mix the two without anyone noticing until search fails. This guide shows how to check for that, how to fix it, and how to choose a font for delivery.
If the text is reversed or its letters don't join, start with reversed Arabic text after PDF to Word. Those problems apply to Urdu files as well.
The letters that cause the trouble
The Unicode Arabic block contains both the Arabic letters and the extra letters used for Urdu, Persian, Sindhi and other languages. Unicode's own annotations mark which is which. These are the pairs that matter most for Urdu text:
| Urdu letter | Urdu character | Arabic look-alike | Notes from Unicode's annotations |
|---|---|---|---|
| ک (kaf) | U+06A9 keheh | U+0643 kaf ك | keheh is listed for Persian, Urdu, Sindhi |
| ی (choti ye) | U+06CC Farsi yeh | U+064A yeh ي | Farsi yeh has no dots at the end of a word; listed for Arabic, Persian, Urdu, Kashmiri |
| ے (bari ye) | U+06D2 yeh barree | none | marked Urdu; rarely confused, but check that OCR didn't turn it into ی |
| ہ (choti he) | U+06C1 heh goal | U+0647 heh ه | heh goal is marked Urdu |
| ھ (do-chashmi he) | U+06BE heh doachashmee | U+0647 heh ه | forms the aspirated letters such as بھ, پھ, کھ |
| ۃ (Urdu teh marbuta) | U+06C3 | U+0629 ة | marked Urdu; appears in Arabic loanwords |
| ۴ ۶ ۷ (digits) | U+06F4, U+06F6, U+06F7 | U+0664, U+0666, U+0667 | Unicode notes Urdu uses different glyphs from Persian for these |
The heh pair causes the most damage. Urdu separates choti he (ہ) from do-chashmi he (ھ), and the second one is part of aspirated sounds: کھ is not کہ. Arabic ه can stand in for either, so a file that uses it has lost a distinction the original print made.
While writing this guide we checked these characters with Python 3.11's unicodedata module
(Unicode 14.0.0). Unicode normalisation (NFKC) leaves every one of them unchanged: keheh stays
keheh and kaf stays kaf. Normalising a file therefore doesn't fix a mix of Arabic and Urdu
letters. You have to replace them deliberately.
Step 1: find out which characters the file contains
Looking at the text won't tell you, because many fonts draw ک and ك, or ی and ي in some positions, almost identically. Test the characters themselves.
- Search for each Arabic look-alike. Open Find (Ctrl+F) and search for ك, ي and ه.
To type a character you don't have on your keyboard, Microsoft documents that you can type
its hexadecimal code, for example
0643, and press Alt+X in Word to turn it into the character. Copy it into the Find box from there. - Count the hits. In an Urdu text, Arabic ك should be close to zero. Arabic ي may appear in quoted Arabic passages. Arabic ه is the hardest: it can be legitimate in quoted Arabic, so look at where the hits are, not just how many there are.
- Search for the Urdu forms too. If ک (
06A9) and ہ (06C1) return nothing, the whole file uses the Arabic letters and a single replacement may fix it. If both forms appear, the file is mixed, which is more common when pages were processed separately or edited later. - Check the digits. Search for ۴ (
06F4) and ٤ (0664). Pick one form for the file and note which one in your delivery message.
Step 2: replace the wrong letters
Work on a copy, with Track Changes off, and replace one letter at a time:
| Replace | With | When it's safe |
|---|---|---|
| ك U+0643 | ک U+06A9 | almost always, unless the file quotes Arabic text |
| ي U+064A | ی U+06CC | in Urdu passages; leave quoted Arabic alone |
| ه U+0647 | ہ U+06C1 or ھ U+06BE | never as one blanket replacement: decide by context |
For heh, a blanket replacement either breaks every aspirated letter or every ordinary he. A safer order is to fix the aspirated pairs first: replace بہ with بھ only where the scan shows do-chashmi he, and so on for پ, ت, ٹ, ج, چ, د, ڈ, ک and گ. Then deal with the remaining Arabic ه. If the book quotes Arabic, such as Qur'anic verses, hadith or Arabic poetry, select only the Urdu passages before you replace, or use Find Next and Replace one hit at a time.
Illustrative example. Suppose a converted Urdu commentary has every ک stored as Arabic ك, while the Arabic hadith it quotes use ك correctly. Search for کتاب finds nothing. Replacing all ك with ک fixes the commentary, but it also changes the quoted Arabic to Urdu letters, so a reader searching the hadith with an Arabic keyboard will miss them. Replacing only inside the Urdu paragraphs keeps both searchable.
After replacing, read one page back against the scan. The text should look the same as it did before. If it changes visibly, you have probably replaced a letter that was right.
Step 3: set the language so Word checks it as Urdu
Select the Urdu text and set its proofing language to Urdu. Microsoft describes this under Review > Language > Set Proofing Language. If Urdu paragraphs are tagged as Arabic, the spell checker either ignores them or flags almost every word. Whether Word can actually spell-check Urdu depends on the proofing tools installed with your copy of Office, so check the language list before you rely on it.
Step 4: choose a delivery font
Nastaliq is the style most Urdu readers expect, but the recipient needs a font that is installed on their system.
- Urdu Typesetting is Microsoft's Nastaliq font. Microsoft Learn describes it as based on the Nastaliq style in the Eastern or Pakistani tradition, intended for general texts such as correspondence, reports and newspapers, and "not intended for setting religious or scholarly text". It is included with Microsoft products rather than sold separately, so a recipient on a Mac may not have it.
- Third-party Nastaliq fonts such as Jameel Noori Nastaleeq are widely used for books. If you use one, confirm the recipient has it, or deliver a PDF alongside the Word file so the layout can be checked.
- A Naskh font is the safe choice when the file goes to a translator or into a database. The text stays the same Unicode characters, only the appearance changes, and Naskh fonts are far more widely installed.
Changing the font never fixes the letters themselves. A file with Arabic ك stays broken in Nastaliq: search and sorting still see the Arabic character.
Pre-delivery checklist for an Urdu Word file
- Arabic ك (U+0643) searched for; hits are only in quoted Arabic
- Arabic ي (U+064A) searched for; hits are only in quoted Arabic
- Arabic ه (U+0647) reviewed by context; aspirated letters use ھ
- ے and ی are distinct and match the scan
- One digit form used throughout, and named in the delivery note
- Three common words searched and found, such as ہے, کے and کی
- Urdu paragraphs tagged as Urdu, quoted Arabic tagged as Arabic
- Every paragraph set to right-to-left
- Delivery font installed on the recipient's system, or a PDF sent alongside
- One sample page read back against the scan after replacements
For the wider content checks (page coverage, footnotes, proofreading a sample and cleaning hidden data), use our QA checklist before delivery. For Arabic-specific search problems such as hamza, tashkeel and tatweel, see why Find can't locate Arabic words.
Where ScribeTools fits
ScribeTools converts scanned and photographed documents in Arabic, Urdu and nearly any other language into editable Word, searchable PDF, plain text and other formats. It is built for long printed editions as well as single documents; see digitizing Arabic books and Arabic PDF to Word. Whatever tool you use, run the letter checks above on the output and review it against the scan before anyone relies on it.
Limitations
- These checks find the wrong character. They don't find a wrong word made of correct characters; only reading against the scan catches that.
- Heh needs a judgement call on each word. No search-and-replace rule fixes it safely in every text.
- Some Urdu writers and publishers use conventions that differ from the table above, for example in loanwords or older printed books. Match the source edition and say so in your delivery note.
- How Word shows the Find dialog, Alt+X and the proofing languages varies between Windows, Mac and the web version. The steps above follow Microsoft's documentation for Word on Windows.
- Older Urdu files made in InPage or with pre-Unicode fonts use different encodings altogether. This guide assumes a Unicode Word file.
Sources
- Unicode Consortium: Arabic code chart (U+0600–U+06FF)
- Unicode Consortium: NamesList.txt (character annotations)
- Microsoft Learn: Urdu Typesetting font
- Microsoft Support: Insert a symbol using the keyboard with ASCII or Unicode character codes
- Microsoft Support: Check spelling and grammar in a different language