Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arabic Problem Replace أً with just ا

How to replace the alf bel tanween with a normal alf

like image 249
Baharanji Avatar asked Jan 13 '11 16:01

Baharanji


2 Answers

I don't know C#, but that's more a UNICODE question. I would do it by means of UNICODE normalization, using this function.

First, normalize to decomposed form. Next, filter out all characters from the "Mark, Nonspacing" category [Mn]. Finally, normalize back to composed form.

If I see correctly, your glyph is represented in UNICODE by ARABIC LETTER ALEF WITH HAMZA ABOVE (U+0623, [Lo]) followed by ARABIC FATHATAN (U+064B, [Mn]). The first character decomposes to ARABIC LETTER ALEF (U+0627, [Lo]) + ARABIC HAMZA ABOVE (U+0654, [Mn]).

Here's the chain of transformations (the first arrow indicates a decomposition, the second – filtering out nonspacing marks, the third – a composition):

U+0623 + U+064B → U+0627 + U+0654 + U+064B → U+0627 → U+0627

After you decompose, remove all the characters from the [Mn] category, and compose back, you're left with ARABIC LETTER ALEF only.

like image 166
Bolo Avatar answered Sep 22 '22 00:09

Bolo


Take a look at this project which provides examples of how to replace unicode characters in strings: http://www.codeproject.com/KB/string/FontGlyphSet.aspx

See also:

  • How to replace text in string in C#?
  • Manipulating both unicode and ASCII character set in C#
like image 41
JYelton Avatar answered Sep 22 '22 00:09

JYelton