-
Notifications
You must be signed in to change notification settings - Fork 8
/
FarsiType.h
151 lines (137 loc) · 5.25 KB
/
FarsiType.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#pragma once
#include <iostream>
#include <string>
#include <vector>
enum FarsiArabicTashkeel_
{
fat_FATHEH,
fat_TANVIN_NASB,
fat_ZAMMEH,
fat_TANVIN_RAF,
fat_KASREH,
fat_TANVIN_JARR,
fat_SOKOON,
fat_TASHDID,
fat_Tashkeel_Count
};
enum FarsiArabicTashkeel_ArabicNames_
{
fat_FATHA = fat_FATHEH,
fat_FATHA_TAN = fat_TANVIN_NASB,
fat_DAMMA = fat_ZAMMEH,
fat_DAMMA_TAN = fat_TANVIN_RAF,
fat_KASRA = fat_KASREH,
fat_KASRA_TAN = fat_TANVIN_JARR,
fat_SUKUN = fat_SOKOON,
fat_SHADDA = fat_TASHDID
};
enum FarsiArabicAlphabets_
{
faa_ALEF_HAMZEH_ABOVE, // أ
faa_ALEF, // ا
faa_ALEF_MAD_ABOVE, // آ
faa_HAMZEH, // ء
faa_VAAV_HAMZEH_ABOVE, // ؤ
faa_ALEF_HAMZEH_BELOW, // إ
faa_YEH_HAMZEH_ABOVE, // ئ
faa_BEH, // ب
faa_PEH, // پ
faa_TEH, // ت
faa_TEH_TANIS, // ة
faa_SEH, // ث
faa_JEEM, // ج
faa_CHEH, // چ
faa_HEH_JEEMY, // ح
faa_KHEH, // خ
faa_DAAL, // د
faa_ZAAL, // ذ
faa_REH, // ر
faa_ZEH, // ز
faa_JEH, // ژ
faa_SEEN, // س
faa_SHEEN, // ش
faa_SAAD, // ص
faa_ZAAD, // ض
faa_TAAH, // ط
faa_ZAAH, // ظ
faa_AIN, // ع
faa_GHAIN, // غ
faa_FEH, // ف
faa_QAAF, // ق
faa_KAAF, // ک
faa_KAAF_NO_HEAD, // ك
faa_GAAF, // گ
faa_LAAM, // ل
faa_MEEM, // م
faa_NOON, // ن
faa_VAAV, // و
faa_HEH, // ه
faa_YEH, // ی
faa_ARABIC_YEH, // ي
faa_ALEF_MAKSURA, // ى
faa_TATWEEL, // ـ
faa_LAAM_ALEF, // لا
faa_LAAM_ALEF_HAMZA_ABOVE, // لأ
};
enum FarsiArabicAlphabets_ArabicNames_
{
faa_ALEF_HAMZA_ABOVE = faa_ALEF_HAMZEH_ABOVE,
faa_ALEF_MADDA_ABOVE = faa_ALEF_MAD_ABOVE,
faa_HAMZA = faa_HAMZEH,
faa_WAAW_HAMZA_ABOVE = faa_VAAV_HAMZEH_ABOVE,
faa_ALEF_HAMZA_BELOW = faa_ALEF_HAMZEH_BELOW,
faa_YEH_HAMZA_ABOVE = faa_YEH_HAMZEH_ABOVE,
faa_TEH_MARBUTA = faa_TEH_TANIS,
faa_THEH = faa_SEH,
faa_HAH = faa_HEH_JEEMY,
faa_THAAL = faa_ZAAL,
faa_ZAIN = faa_ZEH,
faa_DAAD = faa_ZAAD,
faa_KAAF_ARABIC = faa_KAAF_NO_HEAD,
faa_KEHEH = faa_KAAF,
faa_WAAW = faa_VAAV
};
enum FarsiArabicAlphabets_Forms_
{
faa_Unicode,
faa_Isolated,
faa_Beginner,
faa_Medium,
faa_Final,
};
extern const std::vector<std::vector<std::string>> fa_AlphabetsAllForms;
namespace FarsiType
{
/// <summary>Get Farsi/Arabic character place in a word for its form, depending its previous and next character.</summary>
/// <param name="fa_character">Character you want to check its place.</param>
/// <param name="prevFAChar">Previous character, to check if its connected to fa_character or not.</param>
/// <param name="nextFAChar">Next character, to check if its connected to fa_character or not.</param>
/// <returns>Returns an int in type of a char. Possible values: 0- no connection, 1- conntected from behind, 2- connected from front, 3- connected from both side.</returns>
unsigned char GetFACharPlace(const std::string &fa_character, const std::string &prevFAChar, const std::string &nextFAChar);
/// <summary>Check if given character is a Farsi/Arabic letter in beginner form or not.</summary>
/// <param name="fa_character">Character you want to check.</param>
/// <returns>Returns a bool value. Possible values: true, false.</returns>
bool IsFACharBeginner(const std::string &fa_character);
/// <summary>Find vector index of the give character in fa_AlphabetsAllForms vector</summary>
/// <param name="fa_character">Character you want get its index.</param>
/// <returns>Returns an int in type of a char. Possible values: 0 to 44 (fa_AlphabetsAllForms array size).</returns>
unsigned char FindFACharIndex(const std::string &fa_character);
/// <summary>Check if given character is a Farsi/Arabic letter or not.</summary>
/// <param name="fa_character">Character you want to check.</param>
/// <returns>Returns a bool value. Possible values: true, false.</returns>
bool IsFAChar(const std::string &fa_character);
/// <summary>Reverses Farsi/Arabic string and returns a vector of std::strings, each of them containing Farsi/Arabic letters with different byte counts.</summary>
/// <param name="str">Farsi/Arabic string.</param>
/// <returns>Returns a vector of std::strings.</returns>
std::vector<std::string> ReverseFAText(const std::string &str);
/// <summary>Get correct unicode of Farsi/Arabic letter depending on its position, previous, and next letters.</summary>
/// <param name="fa_character">Character you want to check.</param>
/// <param name="prevFAChar">Previous character, to check if its connected to fa_character or not.</param>
/// <param name="nextFAChar">Next character, to check if its connected to fa_character or not.</param>
/// <returns>Returns a std::string.</returns>
std::string GetFACharGlyph(const std::string &fa_character, const std::string &prevFAChar, const std::string &nextFAChar);
/// <summary>Converts a Farsi/Arabic string to a normal, fixed, not-reversed string for using it in you program :).</summary>
/// <param name="text">Farsi/Arabic text.</param>
/// <returns>Returns a std::string. Fixed Farsi/Arabic string</returns>
std::string ConvertToFAGlyphs(const std::string &text);
};