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.
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.
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.
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>
usingnamespace 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.
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 =]
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)
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.
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.)