开发者

How to Join Arabic letters to form words

开发者 https://www.devze.com 2023-04-04 14:32 出处:网络
I have to read arabic letters from xml file and di开发者_如何学运维splay them as a word input :س ع ا د ة

I have to read arabic letters from xml file and di开发者_如何学运维splay them as a word

input :س ع ا د ة output :سعادة look like that ..

I dont know how do that in any language , what algorithm to read, I need some start point to acomplish this task

I am also not sure if i have added the right tags, please free to make changes.


Unless you've been tasked with writing a system GUI level rendering/layout engine, eSniff's answer is almost certainly not what you want to do. This combining of Arabic letters will be done for you by the windowing system, as explained briefly on the Wikipedia page. In almost all circumstances, you should avoid the legacy Arabic presentation forms character code points. Just have a String of the basic Unicode Arabic codepoints and send them to a text field in your UI, and they will be rendered correctly....


For ref: http://en.wikipedia.org/wiki/Arabic_alphabet and http://en.wikipedia.org/wiki/Arabic_characters_in_Unicode

Firstly, I don't know much about Arabic word forms and I just read the Wikipedia doc on it (linked above). Thanks for giving me a reason to read up on it but forgive me if I totally mess this up :-)...

The problem seems to be mapping the char to it's correct "case" based on it's position in the word, right? I'm basing this on the changes you showed in your examples. Anyway, in English this would be like upper-casing the the first letter. In Arabic it appears there are 4 char cases( Beginning, Middle, End and Isolated ). If this is correct here is an example in C# which does this mapping:

class ArabicMapper
{ 
    enum CaseMap{End=0, Middle=1, Beginning=2, Isolated=3};
    Dictionary<char, char[]> charMap; // This maps base letters to one of their four cases.
    public ArabicMapper()
    {
        //Create the char map for each letter in the alphabet. {BaseLetter, {End, Middle, Beginning, Isolated}}
        charMap = new Dictionary<char, char[]>();
        charMap.Add(0627, new char[] { FE8D, 0627, 0627, FE8E }); // ʾalif : Not sure of the rules for middle/beginning, so just using the isolated...
        charMap.Add(0628, new char[] { FE90, FE92, FE91, FE8F }); // bāʾ :
        //... and so on for each char ...

    }
    public string charsToWord(char[] word)
    {

        if (word.Length >= 2)
        {
            StringBuilder finalWord = new StringBuilder();

            for(int i=0; i<word.Length; i++)
            {
                if (i == 0)
                    finalWord.Append((charMap[word[i]])[CaseMap.Beginning]);
                else if(i == word.Length-1)
                    finalWord.Append((charMap[word[i]])[CaseMap.End]);
                else
                    finalWord.Append((charMap[word[i]])[CaseMap.Middle]);
            }
            return finalWord.ToString();
        }
        else
        {
            (charMap[word[0]])[CaseMap.Isolated].ToString();
        }
    }
}

P.S. I didn't test this code so it may not work. Treat it as pseudocode, please.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号