Click here to Skip to main content
Click here to Skip to main content

Persian Support for Windows CE

, 10 Apr 2006 CPOL
Rate this:
Please Sign up or sign in to vote.
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:

#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):

//////////////////////////////////////////////////////////////////////
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:

//////////////////////////////////////////////////////////////////////
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)

Share

About the Author

Hamid Reza Mohammadi
Software Developer
Iran (Islamic Republic Of) Iran (Islamic Republic Of)
No Biography provided

Comments and Discussions

 
Generalthanks, and i need a keyboard Pinmemberaram_golbaghi18-Jul-10 23:09 
Generalthnx Pinmemberkavosh139-Oct-09 0:29 
GeneralGood Coding PinmemberNNTBIZ24-Apr-09 22:05 
GeneralConverted to VB version of arabize function for persian support in win CE PinmemberAhmad Abrishami30-May-08 21:37 
GeneralThanks Pinmemberjavadpishvaei23-May-07 11:40 
NewsExcellent! PinmemberA. Riazi12-Apr-06 20:13 
Thanks for sharing your knowledge.
 
Best regards,
A. Riazi

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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
Web03 | 2.8.141216.1 | Last Updated 10 Apr 2006
Article Copyright 2006 by Hamid Reza Mohammadi
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid