Click here to Skip to main content
12,295,791 members (27,922 online)
Click here to Skip to main content
Add your own
alternative version


48 bookmarked

Arabic Support for Windows CE

, 19 Jan 2003 CPOL
Rate this:
Please Sign up or sign in to vote.
This article explains how to support the Arabic language in your applications written for Windows CE.

Sample Image - arabicsupport.gif


When Microsoft Windows CE first came to life and the number of PDAs based on it increased rapidly, the software market was opened widely for a new type of applications and we all wanted to write new applications or to port our application already written for Win32 to Windows CE. Unfortunately, for the Arabic market, there is no Arabic language support in WinCE 2.11 and WinCE 3.0.

After a long time some third parties introduced some solutions and each claimed “We have the first and best Arabic Language Support for Windows CE (or PocketPC)”. They offered their solutions for a big amount of what is called “money”. Too big for a poor freelance programmer to handle. And after one of the companies offering the solution asked me $5000 for their solution (don’t tell them I told you it was bad), I started to write the first and best Arabic Language support for Windows CE myself. It was about 14 months ago. And here is what I did.

Problem Identification

The main problem is that the WinCE 2.11 and WinCE 3.0 do not have intrinsic support for BiDi (Bi-Directional) fonts and RTL (Right To Left) window controls. I don’t know why. I think it’s not too difficult and I also think that, it will not take much memory nor processing time to support those features.

Before I go deep with you, I wanted you to notice what an Arabic support solution makes to a string to be displayed the right way on a window.

The Arabic string is stored from left to right as in English. But when it’s to be displayed, the first character in the string should be the right most character. Further, in Arabic, the character can take more than one glyph (figure or shape) depending on its position in the word: at first, in middle, at last, and alone. In Arabic Enabled Windows and Unicode ready Windows (Windows 2000 and up) all this is implemented intrinsically in the GDI. In WinCE we have to do this ourselves.

The solution

First, You have to install an Arabic TrueType font. The Tahoma of Arabic-Enabled Windows is great.

Arabization involves reversing the string, considering that numbers shouldn’t be reversed and perform glyph substitution manually.

To reverse the string I use:

void ArabicReverse(CString &s)
    CString out, rev;

    int i=0;
        if((s[i]>='0' && s[i]<='9'))    // isDigit(s[i]) ?
            while((s[i]>='0' && s[i]<='9'))    // isDigit(s[i]) ?
                rev = rev + s[i];
            out = out + rev;
            out = out + s[i];

The second step is a bit more tricky so be ready. We know that the Arabic string in the memory contains the Unicode characters that take the same form of the isolated glyphs of the letters. We have to make mapping from the character to the right glyphs to be displayed, considering all states of the letter.

I some how could construct an array of all Arabic letters' state. It is not sorted alphabetically. The first row in the table is the first piece of data I could collect about a letter and it was the letter ‘thal’.

As far as I know .. the rules of glyph substitution are somewhere in the TTF file but I found it very complex. To help constructing the rules for glyph substitution, I made two sets of characters according to whether it may need a link to the previous or the next character.

CString Arabize (LPCTSTR in)
    static struct
        WCHAR character;
        WCHAR endGlyph;
        WCHAR iniGlyph;
        WCHAR midGlyph;
        WCHAR isoGlyph;
        {0x630, 0xfeac, 0xfeab, 0xfeac, 0xfeab},
        {0x62f, 0xfeaa, 0xfea9, 0xfeaa, 0xfea9},
        {0x62c, 0xfe9e, 0xfe9f, 0xfea0, 0xfe9d},
        {0x62d, 0xfea2, 0xfea3, 0xfea4, 0xfea1},
        {0x62e, 0xfea6, 0xfea7, 0xfea8, 0xfea5},
        {0x647, 0xfeea, 0xfeeb, 0xfeec, 0xfee9},
        {0x639, 0xfeca, 0xfecb, 0xfecc, 0xfec9},
        {0x63a, 0xfece, 0xfecf, 0xfed0, 0xfecd},
        {0x641, 0xfed2, 0xfed3, 0xfed4, 0xfed1},
        {0x642, 0xfed6, 0xfed7, 0xfed8, 0xfed5},
        {0x62b, 0xfe9a, 0xfe9b, 0xfe9c, 0xfe99},
        {0x635, 0xfeba, 0xfebb, 0xfebc, 0xfeb9},
        {0x636, 0xfebe, 0xfebf, 0xfec0, 0xfebd},
        {0x637, 0xfec2, 0xfec3, 0xfec4, 0xfec1},
        {0x643, 0xfeda, 0xfedb, 0xfedc, 0xfed9},
        {0x645, 0xfee2, 0xfee3, 0xfee4, 0xfee1},
        {0x646, 0xfee6, 0xfee7, 0xfee8, 0xfee5},
        {0x62a, 0xfe96, 0xfe97, 0xfe98, 0xfe95},
        {0x627, 0xfe8e, 0xfe8d, 0xfe8e, 0xfe8d},
        {0x644, 0xfede, 0xfedf, 0xfee0, 0xfedd},
        {0x628, 0xfe90, 0xfe91, 0xfe92, 0xfe8f},
        {0x64a, 0xfef2, 0xfef3, 0xfef4, 0xfef1},
        {0x633, 0xfeb2, 0xfeb3, 0xfeb4, 0xfeb1},
        {0x634, 0xfeb6, 0xfeb7, 0xfeb8, 0xfeb5},
        {0x638, 0xfec6, 0xfec7, 0xfec8, 0xfec5},
        {0x632, 0xfeb0, 0xfeaf, 0xfeb0, 0xfeaf},
        {0x648, 0xfeee, 0xfeed, 0xfeee, 0xfeed},
        {0x629, 0xfe94, 0xfe93, 0xfe93, 0xfe93},
        {0x649, 0xfef0, 0xfeef, 0xfef0, 0xfeef},
        {0x631, 0xfeae, 0xfead, 0xfeae, 0xfead},
        {0x624, 0xfe86, 0xfe85, 0xfe86, 0xfe85},
        {0x621, 0xfe80, 0xfe80, 0xfe80, 0xfe7f},
        {0x626, 0xfe8a, 0xfe8b, 0xfe8c, 0xfe89},
        {0x623, 0xfe84, 0xfe83, 0xfe84, 0xfe83},
        {0x622, 0xfe82, 0xfe81, 0xfe82, 0xfe81},
        {0x625, 0xfe88, 0xfe87, 0xfe88, 0xfe87}
    BOOL linkBefore, linkAfter;
    CString out;
    for(UINT i=0; i<_tcslen(in); i++)
        WCHAR ch=in[i];
        if(((ch>=0x0621 && ch<=0x064a)) // is an Arabic character?
            int idx = 0;
            while (idx < N_DISTINCT_CHARACTERS)
                if (a[idx].character == in[i])
            if(i == _tcslen(in) - 1)
                linkAfter = (isFromTheSet1(in[i+1]) || 
            if(i == 0)
            if(linkBefore && linkAfter)
                out.SetAt(i, a[idx].midGlyph);
            if(linkBefore && !linkAfter)
                out.SetAt(i, a[idx].endGlyph);
            if(!linkBefore && linkAfter)
                out.SetAt(i, a[idx].iniGlyph);
            if(!linkBefore && !linkAfter)
                out.SetAt(i, a[idx].glyph);
    ArabicReverse (out);
    return out;
BOOL BzArabicRender::isFromTheSet1(WCHAR ch)
    static WCHAR theSet1[22]={
        0x62c, 0x62d, 0x62e, 0x647, 0x639, 0x63a, 0x641, 0x642,
        0x62b, 0x635, 0x636, 0x637, 0x643, 0x645, 0x646, 0x62a,
        0x644, 0x628, 0x64a, 0x633, 0x634, 0x638};
    int i = 0;
    while (i < 22)
        if(ch == theSet1[i])
            return TRUE;
    return FALSE;
BOOL BzArabicRender::isFromTheSet2(WCHAR ch)
    static WCHAR theSet2[12]={
        0x627, 0x623, 0x625, 0x622, 0x62f, 0x630, 0x631, 0x632,
        0x648, 0x624, 0x629, 0x649};
    int i = 0;
    while (i < 12)
        if(ch == theSet2[i])
            return TRUE;
    return FALSE;

To use this .. just SetWindowText the window you want to the output of the Arabize().

window.SetWindowText(str); //before
window.SetWindowText(Arabize(str)); //after


dc.DrawText(str,……); //before
dc.DrawText(Arabize(str),……); //after

… etc

So there is not much change in code if you already have written old code for English.

Of course it’s not the ideal solution. I think the optimum solution is to hook the DrawText function and add all this stuff. But when I wrote this code there was no online material showing how to hook Windows CE APIs.

I will update the document to show how to retrieve the characters from the glyphs to process them soon. Or it may be another article.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Mohamed Abdel-Monem
Chief Technology Officer
Egypt Egypt
No Biography provided

You may also be interested in...

Comments and Discussions

Questionarabic issue Pin
danishjee2-May-12 4:27
memberdanishjee2-May-12 4:27 
AnswerRe: arabic issue Pin
emranallan11-May-12 14:58
memberemranallan11-May-12 14:58 
QuestionArabic problem in Windows CE 6 Pin
Waseem Al Mustafa20-Apr-12 8:33
memberWaseem Al Mustafa20-Apr-12 8:33 
AnswerRe: Arabic problem in Windows CE 6 Pin
emranallan11-May-12 15:01
memberemranallan11-May-12 15:01 
GeneralRe: Arabic problem in Windows CE 6 Pin
Waseem Al Mustafa15-May-12 0:32
memberWaseem Al Mustafa15-May-12 0:32 
GeneralRe: Arabic problem in Windows CE 6 Pin
emranallan15-May-12 4:02
memberemranallan15-May-12 4:02 
Hello sir ;

i already submit code here
Arabic Controls in Window phone 7

go here and copy the code from the article if you got any problem please let me know

public string DisplayArabic(string s)//this function take unshaped string ,then convert it to shaped look return value.
BTW ;if you need support for this article please add your comment there

emran allan

AnswerRe: Arabic problem in Windows CE 6 Pin
Waseem Al Mustafa16-May-12 1:39
memberWaseem Al Mustafa16-May-12 1:39 
Questionarabizer + Win CE Pin
maria anders27-Mar-12 20:45
membermaria anders27-Mar-12 20:45 
AnswerRe: arabizer + Win CE Pin
emranallan11-May-12 15:04
memberemranallan11-May-12 15:04 
QuestionWhy ARABIC LETTER PEH is not shown correctly on Android 3.x? Pin
breceivemail9-Oct-11 21:56
memberbreceivemail9-Oct-11 21:56 
GeneralNot supporting some combined fonts Pin
sureshthapa26-Feb-11 23:42
membersureshthapa26-Feb-11 23:42 
Generalhave problem in code Pin
rezam69130-Mar-10 5:44
memberrezam69130-Mar-10 5:44 
GeneralNice work! Pin
Md. Ali Naser Khan7-May-09 0:20
memberMd. Ali Naser Khan7-May-09 0:20 
GeneralNice work... Pin
BabakAnsari25-Jan-09 19:33
memberBabakAnsari25-Jan-09 19:33 
QuestionRe: Nice work... Pin
Harishkg2-Apr-09 1:13
memberHarishkg2-Apr-09 1:13 
GeneralRe: Nice work... Pin
nizinizinizi6-Apr-10 17:17
membernizinizinizi6-Apr-10 17:17 
GeneralProblem with 'Arabization' of Urdu Pin
abwd13-Jan-09 13:09
memberabwd13-Jan-09 13:09 
GeneralRe: Problem with 'Arabization' of Urdu Pin
abwd13-Jan-09 20:25
memberabwd13-Jan-09 20:25 
QuestionFinding list of Installed softwares in windows ce device Pin
G.Swamy Suresh27-Nov-08 18:43
memberG.Swamy Suresh27-Nov-08 18:43 
GeneralIf you agree to cooperate with me. Pin
Member 104088618-Oct-08 22:41
memberMember 104088618-Oct-08 22:41 
GeneralC# updated code - Points of concerns Pin
Ahmad El-Helaly21-Aug-08 5:16
memberAhmad El-Helaly21-Aug-08 5:16 
GeneralRe: C# updated code - Points of concerns Pin
Member 68709114-Sep-08 20:19
memberMember 68709114-Sep-08 20:19 
GeneralRe: C# updated code - Points of concerns Pin
Zynur23-Sep-08 16:51
memberZynur23-Sep-08 16:51 
Generaltashkeel character Pin
basicci@hotmail.com23-Jun-08 21:59
memberbasicci@hotmail.com23-Jun-08 21:59 
GeneralConverted to VB version of arabize function for arabic support in win CE Pin
Ahmad Abrishami29-May-08 20:26
memberAhmad Abrishami29-May-08 20:26 
GeneralRe: Converted to VB version of arabize function for arabic support in win CE Pin
basicci@hotmail.com17-Jun-08 1:02
memberbasicci@hotmail.com17-Jun-08 1:02 
QuestionArabic strings stored in XML files Pin
menuthaur10-May-08 2:44
membermenuthaur10-May-08 2:44 
QuestionArabic strings stored in XML files Pin
menuthaur10-May-08 2:44
membermenuthaur10-May-08 2:44 
QuestionArabic strings stored in XML files Pin
menuthaur10-May-08 2:44
membermenuthaur10-May-08 2:44 
GeneralInternet Explorer doesn't render arabic correctly Pin
sherifomran21-Apr-08 11:06
membersherifomran21-Apr-08 11:06 
Generali have problem in Arabic Pages in the internet explorer Pin
Microway24-Mar-08 23:55
memberMicroway24-Mar-08 23:55 
Generalhelp needed Pin
reham6-Feb-08 20:31
memberreham6-Feb-08 20:31 
GeneralFor all people that has problem ASCII to Unicode problem Pin
AhmedEssamNaiem6-Oct-07 0:02
memberAhmedEssamNaiem6-Oct-07 0:02 
Generalproblem with unicode characters Pin
breceivemail5-Aug-07 7:30
memberbreceivemail5-Aug-07 7:30 
Generalfunction Pin
ghazalehb15-Jul-07 23:49
memberghazalehb15-Jul-07 23:49 
GeneralDll Needed Pin
AHMAD REFAAT9-Jul-07 1:30
memberAHMAD REFAAT9-Jul-07 1:30 
Questionno ATL / CString Pin
blotfib5-Jan-07 20:46
memberblotfib5-Jan-07 20:46 
GeneralA couple small changes Pin
David Maung11-May-06 15:04
memberDavid Maung11-May-06 15:04 
QuestionPlease Insert Demo Pin
m_o3015-Apr-06 1:47
memberm_o3015-Apr-06 1:47 
GeneralAny demo code Pin
Tili18-Mar-06 3:58
memberTili18-Mar-06 3:58 
GeneralConsulting Pin
bm_masri24-Dec-05 18:59
memberbm_masri24-Dec-05 18:59 
GeneralArabic Font rendering Pin
Abhi Lahare12-Aug-05 20:54
memberAbhi Lahare12-Aug-05 20:54 
Generalhelp in EVC Pin
Anonymous19-Jul-05 9:20
sussAnonymous19-Jul-05 9:20 
GeneralArabic Keyboard Pin
ataha4-Mar-05 22:15
memberataha4-Mar-05 22:15 
GeneralRe: Arabic Keyboard Pin
AhmedEssamNaiem5-Oct-07 23:11
memberAhmedEssamNaiem5-Oct-07 23:11 
GeneralIsaac Pin
Isaac_cm19-Dec-04 11:18
memberIsaac_cm19-Dec-04 11:18 
GeneralArabic Support Pin
cakiki15-Dec-04 19:39
membercakiki15-Dec-04 19:39 
GeneralTo Mr. Mohamed Abdel-Monem Pin
eyas128-Sep-04 1:45
membereyas128-Sep-04 1:45 
GeneralRe: To Mr. Mohamed Abdel-Monem Pin
eyas128-Sep-04 1:48
membereyas128-Sep-04 1:48 
GeneralRe: To Mr. Mohamed Abdel-Monem Pin
AhmedEssamNaiem5-Oct-07 23:14
memberAhmedEssamNaiem5-Oct-07 23:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160525.2 | Last Updated 20 Jan 2003
Article Copyright 2003 by Mohamed Abdel-Monem
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid