Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reverse of an Arabic string in c++

How an Arabic string can be reversed using C++? For instance, the reverse of كلمة is ةملك. Shape of Arabic letters differs according to position in the word. (initial,medial or final of word). Are there other rules to concatenate Arabic letters?

like image 989
user1766006 Avatar asked Feb 25 '15 14:02

user1766006


1 Answers

As Petesh says and according to the references I can find such as Wikipedia the rendering engine should take of using the appropriate glyphs for you. Quoting the article:

For example, many Arabic letters are represented by a different glyph when the letter appears at the end of a word than when the letter appears at the beginning of a word. Unicode's approach prefers to have these letters mapped to the same character for ease of internal machine text processing and storage. To complement this approach, the text software must select different glyph variants for display of the character based on its context

A quick experiment with an online unicode convertor seem to confirm that:

كلمة

in hex code points is:

0643 0644 0645 0629

while:

ةملك

is:

0629 0645 0644 0643

which is the exact reverse of the previous code points.

like image 152
Shafik Yaghmour Avatar answered Nov 03 '22 10:11

Shafik Yaghmour