سؤال

How to replace the alf bel tanween with a normal alf

هل كانت مفيدة؟

المحلول 3

Thanks to Bolo's enlightment after a couple of minutes of searching i did it like that:

string s = "";
        foreach (Char c in x)
        {
            if (((int)c).ToString("x").ToLower() != "64b")
                s += c.ToString();

        }

where x is my string

Like that I excluded the ARABIC FATHATAN from the string

نصائح أخرى

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.

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:

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top