This article was previously published in my blog, Just Like a Magic.
Introduction
In some languages, like Arabic and Hebrew, you combine some characters with combining characters based on the pronunciation of the word. Combining characters are characters (like diacritics, etc.) that are combined with base characters to change the pronunciation of the word (sometimes called vocalization.) Some examples of combining characters are diacritics:| Base Character | Combining Character(s) | Result | |
| 1 Combining a single character |
|
![]() Arabic Damma 0x064F |
![]() Letter Teh + Damma |
| 2 Combining two characters | ![]() Arabic Letter Teh 0x062A |
|
![]() Letter Teh + Shadda + Fathatan |
When you combine a character with another one then you end up with two characters. When you combine two characters with a base one you end up with 3 characters combined in one, and so on.
Enumerating a String with Base Characters
Now we are going to try an example. This example uses a simple word,
This word (with the diacritics) is consisted of 9 characters, sequentially as following:
- Meem
- Damma (a combining character combined with the previous Meem)
- Kashida
- Hah
- Meem
- Shadda (a combining character)
- Fatha (a combining character both Shadda and Fatha are combined with the Meem)
- Kashida
- Dal
- Meem (have a Damma above)
- Kashida
- Hah
- Meem (have a Shadda and a Fatha above)
- Kashida
- Dal
string someName = "مُـحمَّـد"; |
What we get? When enumerating the string, we enumerate its base characters only.
Enumerating a String with Combining Characters
.NET Framework provides a way for enumerating strings with combining characters, it is via the TextElementEnumerator and StringInfo types (both reside in namespace System.Globalization.) The following code demonstrates how you can enumerate a string along with its combining characters:string someName = "مُـحمَّـد"; |
Comparing Strings
Sometimes, you will be faced with a situation where you need to compare two identical strings differ only by their diacritics (combining characters) for instance. If you were to compare them using the common way (using String.Compare for instance) they would be different because of the combining characters.
To overcome this you will need to use a special overload of String.Compare method:
string withCombiningChars = "مُـحمَّـد"; |
The Kashida ـ isn't of the Arabic alphabets. It's most likely be a space! So the option CompareOptions.IgnoreSymbols ignores it from comparison.
Writing Arabic diacritics
The following table summarizes up the Arabic diacritics and the keyboard shortcut for each character:
| Unicode Representation | Character | Name | Shortcut |
| 0x064B | ![]() |
Fathatan | Shift + W |
| 0x064C | ![]() |
Dammatan | Shift + R |
| 0x064D | ![]() |
Kasratan | Shift + S |
| 0x064E | ![]() |
Fatha | Shift + Q |
| 0x064F | ![]() |
Damma | Shift + E |
| 0x0650 | ![]() |
Kasra | Shift + A |
| 0x0651 | ![]() |
Shadda | Shift + ~ |
| 0x0652 | ![]() |
Sukun | Shift + X |
Using the Character Map Application
Microsoft Windows comes with an application that help you browsing the characters that a font supports. This application is called, Character Map.
You can access this application by typeing charmap.exe into Run, or pressing Start->Programs->Accessories->System Tools->Character Map.
Try it out!
Code examples for the reader to discover:
A. |












sosoPosted Sep 30, 2010, 7:19 AM
please I want to Know how we can add diacritical marks using C#.net or VB.net??