Click here to Skip to main content
15,885,146 members
Articles / Desktop Programming / MFC

Persian Support for Windows CE

Rate me:
Please Sign up or sign in to vote.
4.31/5 (9 votes)
10 Apr 2006CPOL1 min read 40.9K   16   6
This article explains how to extend Mohamed Abdel-Monem's code for Arabic support for Windows CE, to add Persian support to your Windows CE programs.

Windows CE based terminal showing Persian words

Introduction

An enhanced version of Arabic alphabet is used to write in Persian language. The enhancements include some additional symbols for displaying some Persian specific letters including Peh, Cheh, Zheh, Gaf, and a Persian version of Kaf.

A few months ago, I developed a simple data collection program for a Symbol MC3000 Windows CE 4.2 based terminal (you can read its specifications here [Persian]). I used a modified version of the code explained in Mohamed Abdel-Monem's Arabic support for Windows CE for adding Persian support to my program.

The reader is asked to refer to the original article for complete documentation, and I only explain my modifications to the original code here.

Modifications

First of all, I defined N_DISTINCT_CHARACTERS somewhere in my code as below:

C++
#define N_DISTINCT_CHARACTERS 205

The ArabicReverse function needs no modifications.

Modifications in the Arabize function must be applied as below (only commented lines are added or changed):

C++
//////////////////////////////////////////////////////////////////////
CString Arabize (LPCTSTR in)
{
   static struct
    {
        WCHAR character;
        WCHAR endGlyph;
        WCHAR iniGlyph;
        WCHAR midGlyph;
        WCHAR isoGlyph;
    }a[N_DISTINCT_CHARACTERS]=
    {
    ...
    {0x625, 0xfe88, 0xfe87, 0xfe88, 0xfe87},//,
    {0x6A9, 0xfb8f, 0xfb90, 0xfb91, 0xfb8e},//Persian Keh
    {0x6Af, 0xfb93, 0xfb94, 0xfb95, 0xfb92},//Gaf
    {0x698, 0xfb8b, 0xfb8a, 0xfb8b, 0xfb8a},//Zheh
    {0x686, 0xfb7b, 0xfb7c, 0xfb7d, 0xfb7a},//Cheh
    {0x67E, 0xfb57, 0xfb58, 0xfb59, 0xfb56}//Peh
      }
...
      WCHAR ch=in[i];
        if((ch>=0x0621 && ch<=0x064a)||(ch==0x6A9)||(ch==0x6Af)
         ||(ch==0x686)||(ch==0x67E)) // is a Persian character?
...
    return out;
}

In the above code, we add five rows which include the state of Persian specific letters to the original Arabic letters' state array.

The following modifications must also be made to the isFromTheSet1 and isFromTheSet2 methods, to explain how our additional letters must be shown when they are linked to other letters:

C++
//////////////////////////////////////////////////////////////////////
BOOL BzArabicRender::isFromTheSet1(WCHAR ch)
{
    static WCHAR theSet1[27]={//changed from 22 to 27
        0x62c, 0x62d, 0x62e, 0x647, 0x639, 0x63a, 0x641, 0x642,
        0x62b, 0x635, 0x636, 0x637, 0x643, 0x645, 0x646, 0x62a,
        0x644, 0x628, 0x64a, 0x633, 0x634, 0x638,
        0x6Af, 0x6A9,    0x686, 0x67E, 0x626
        //our additional letters: Gaf, Persian Keh, 
        //Cheh, Peh, Yeh with hamza above
        };
    int i = 0;
    while (i < 27)//changed from 22 to 27
    {
        if(ch == theSet1[i])
            return TRUE;
        ++i;
    }
    return FALSE;
}
//////////////////////////////////////////////////////////////////////
BOOL BzArabicRender::isFromTheSet2(WCHAR ch)
{
    static WCHAR theSet2[13]={//changed from 12 to 13
        0x627, 0x623, 0x625, 0x622, 0x62f, 0x630, 0x631, 0x632,
        0x648, 0x624, 0x629, 0x649,
        0x698//our additional letter: Zheh
        };
    int i = 0;
    while (i < 13)//changed from 12 to 13
    {
        if(ch == theSet2[i])
            return TRUE;
        ++i;
    }
    return FALSE;
}

License

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


Written By
Software Developer
Iran (Islamic Republic of) Iran (Islamic Republic of)
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generalthanks, and i need a keyboard Pin
aram_golbaghi18-Jul-10 22:09
aram_golbaghi18-Jul-10 22:09 
Generalthnx Pin
kavosh138-Oct-09 23:29
kavosh138-Oct-09 23:29 
GeneralGood Coding Pin
NNTBIZ24-Apr-09 21:05
professionalNNTBIZ24-Apr-09 21:05 
GeneralConverted to VB version of arabize function for persian support in win CE Pin
Ahmad Abrishami30-May-08 20:37
Ahmad Abrishami30-May-08 20:37 
GeneralThanks Pin
javadpishvaei23-May-07 10:40
javadpishvaei23-May-07 10:40 
NewsExcellent! Pin
Abbas_Riazi12-Apr-06 19:13
professionalAbbas_Riazi12-Apr-06 19:13 
Thanks for sharing your knowledge.

Best regards,
A. Riazi

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.