Click here to Skip to main content
15,891,749 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to perform letter frequency of Arabic characters contained in a sample text, but i don't know how to read the text file containing the Arabic content and how to count the frequency of each characters

for example

البيت الكسز اللتيل الزجاج الست.

where individual letters are

ا أ إ آ ى ؤ ئ ء ب ت ة ث ج ح خ د ذ ر ز س ش ص ض ط ظ ع غ ف ق ك ل م ن ه

How do i detect the code-page a file is written or stored in?
Can it help in this program, because am opening text files created with Arabic language?
Posted

1 solution

Don't repost the same question in multiple places. This has already been answered in the VB.NET forum.
 
Share this answer
 
Comments
Nish Nishant 11-Feb-11 12:26pm    
He's given more info in this thread though. As you can see, the observed characters are actually a combination of multiple characters (or so it would seem based on what he says). So in the first Arabic sentence, it seems there are 5 words where each word seems to be one continuous and long piece of character, but a single character. But in the 2nd piece of Arabic text, he's disassembled them into the individual characters. So from this perspective, it certainly looks as if some non-trivial work needs to be done to extract the individual characters that go into making those composite characters.
Cool Smith 11-Feb-11 13:48pm    
if i convert the whole string to unicode ie u+0000, or \x?? will it work? How do i convert the string to unicode or hex
Dave Kreskowiak 11-Feb-11 20:37pm    
In .NET, all Strings are Unicode. Nish is correct. In order to get the individual characters, you've got a rather complicated problem. There is no way to detect the correct code-page from a text file. The information is simply not in the file.

Try opening the file with a StreamReader using the Encoding option and specify Encoding.Unicode. Read one character at a time and see what you get.
Cool Smith 12-Feb-11 6:30am    
can you provide sample code on how to do this?
Dave Kreskowiak 12-Feb-11 10:08am    
An example to open a file?? http://msdn.microsoft.com/en-us/library/x8xxf0x5.aspx#Y1078

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900