Arabic alphabets

Jul 7, 2009 at 4:07pm
Help needed fellows...
I want to input and display arabic alphabets using Dev C++. I have tried using ascii codes but failed. How can i???
Jul 7, 2009 at 5:32pm
You mean via console window? In which OS? On Windows should be almost impossible
BTW you should use Unicode, not ASCII
Jul 7, 2009 at 6:07pm
Hi,

Arabic is not part of the ASCII. Hebrew and Arabic are the only 2 languages that are written from right to left, and are discribed well in UNICODE. Every character is 2 bytes, while ASCII is 1 byte char.

http://www.unicode.org/

You can use the BIDi-Algorith to embedd arabic and english always , and controll the cursor positions.
Jul 8, 2009 at 4:42am
Thanks bazzy and waelali. i have unicode ranging from 0600 to 06FF. I don't know how to use it as i am a beginner. I will be pleased if you can guide me with an example. Thanks to everyone.
I am using windows.
Last edited on Jul 8, 2009 at 4:43am
Jul 8, 2009 at 1:45pm
You need to set the console code page to 65001 and the font to "Lucida Console" (I think that has Arabic characters -- I know it does not have Hebrew characters). This will allow the console to read and display your Arabic characters.

I've never messed with a Right-To-Left language like Arabic or Hebrew on the console before, so I don't know what else needs to be done to accomodate it.

I think you'll also need to change the current system locale.

There are these links I found:
http://www.microsoft.com/middleeast/arabicdev/Windows/winMEDIA/wPapers_mediaServices.aspx
http://msdn.microsoft.com/en-us/library/dd318054(VS.85).aspx

That last link is somewhat disappointing, but it is noteworthy also that perhaps you'll want some other output medium to display your text...

That's all I know. Hope it helps.
Jul 9, 2009 at 2:05pm
Jul 9, 2009 at 3:45pm
Thanks Duoas. Still some help needed.... Current CP identifier is 437. I want it to be 864. I wrote following code but it failed.
1
2
3
4
5
6
7
8
9
10
11
12
13
#include<iostream>
#include<windows.h>
using namespace std;
int main()
{
      int a=864;
      if ((SetConsoleCP(a)==0))
      cout<<"CP not changed."<<endl;
      else
      cout<<"CP changed to "<<a<<endl;
      system("PAUSE");
      return 0;
}

SetConsoleCP() requires UINT, unsigned int as input.
Jul 9, 2009 at 4:50pm
It's working fine for me. The only thing I can think of that could go wrong is that you're not using one of the NT kernels (post Windows 2000).
Jul 10, 2009 at 5:09am
I am using windows XP and Dev C++. How to use NT kernels and why?
Jul 10, 2009 at 5:19am
http://en.wikipedia.org/wiki/Windows_NT
First paragraph should clear that up for you

SetCurrentConsoleFontEx() only works on Vista and later

int -> unsigned int is an implicit conversion

It's failing for me as well. GetLastError returns "The parameter is incorrect."

Ok so I read SetConsoleCP's parameter and noticed the code pages are stored in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage so I open up regedit and head to the key.

I see the values and look for 864 yet it doesn't have any data ;) I noticed my 863 DID IN FACT have data (c_863.nls)

I changed the value to 863 and it worked. So I've concluded that because there is no data in 864 it failed. I'm very interested in this thread could someone please help me with this too?

Should have looked through Duoas's links before posting =]
Last edited on Jul 10, 2009 at 5:37am
Jul 10, 2009 at 5:36am
But it works for helios. What should i do to make it work for XP?
Jul 10, 2009 at 5:39am
Read http://www.microsoft.com/middleeast/arabicdev/Windows/winMEDIA/wPapers_mediaServices.aspx (Duoas posted this)

It works for helios because he has the language pack installed (I assume that's why and I don't actually have my windows xp installer disc right now to try it out)
Last edited on Jul 10, 2009 at 5:44am
Jul 10, 2009 at 5:39am
But arabic alphabets have ASCII codes in CP 864. I want that. Thanks mackabee. Now CP changes to 864 but no change in alphabets. Is it necessary to change the whole configuration of OS to arabic??? I just want to input and display some arabic alphabets in C++ console window.
Last edited on Jul 10, 2009 at 6:09am
Jul 12, 2009 at 8:25am
Is there no solution for my problem.....
Jul 12, 2009 at 1:42pm
Alas, not that I know of...

The Windows Console really isn't designed for Arabic text.
Jul 12, 2009 at 2:03pm
you mean i should use another language...
Jul 12, 2009 at 2:05pm
No, I mean that you should display your text on something other than the console.

The western world has been fairly Anglo-centric about languages used in computing. Just getting things like diacritics for languages like Español is a hassle -- messing with code pages and the like.

Arabic has several things working against it when working in such a narrow view of the world:
-- it is read right-to-left
-- its letters change shape depending on adjacency (they are connected --unlike in European languages where each letter is a thing by itself)

The Windows Console simply isn't designed to be able to handle right-to-left scripts like Arabic and Hebrew. However, while googling for information to help you, I have come across a number of sites dedicated to using Hebrew in the console. These may help you. You'll just have to change the font to display Arabic glyphs rather than Hebrew. (Hebrew also has some letterform changes based upon its location in a word -- though they don't ever connect together.)
Last edited on Jul 12, 2009 at 2:13pm
Jul 13, 2009 at 3:08am
Thanks Duoas, you have helped me a lot in this problem. And thanks to all.
Topic archived. No new replies allowed.