-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.js
executable file
·354 lines (287 loc) · 8.83 KB
/
common.js
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
/******************************************
This file is part of Bangla Unicode Web Tools 2.
Copyright (C) 2007 S M Mahbub Murshed
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Contains common utilities to:
- Determine bangla character category
- Find equivalent kar to sorborno mapping
Author: S M Mahbub Murshed
Email: [email protected]
Version: 1.2.0
Date: September 06, 2006, XX:XX GMT
*******************************************/
/******************************************
Determines whether the unicode
character is an bangla digit
character or not.
\param CUni The Unicode character
Coded by : S M Mahbub Murshed
Date: August 28, 2006
*******************************************/
function IsBanglaDigit(CUni)
{
if(CUni=='০' || CUni=='১'
|| CUni=='২' || CUni=='৩'
|| CUni=='৪' || CUni=='৫'
|| CUni=='৬' || CUni=='৭'
|| CUni=='৮' || CUni=='৯')
return true;
return false;
} // end function IsBanglaDigit
/******************************************
Determines whether the unicode
character is a bangla pre kar
character or not. Pre kar
character are appended BEFORE
a banjonborno or juktakhor character
after rendering.
\param CUni The Unicode character
Coded by : S M Mahbub Murshed
Date: August 28, 2006
*******************************************/
function IsBanglaPreKar(CUni)
{
if(CUni=='ি' || CUni=='ৈ'
|| CUni=='ে' )
return true;
return false;
} // end function IsBanglaPreKar
/******************************************
Determines whether the unicode
character is a bangla post kar
character or not. Post kar
character are appended AFTER
a banjonborno or juktakhor character
after rendering.
\param CUni The Unicode character
Coded by : S M Mahbub Murshed
Date: August 28, 2006
*******************************************/
function IsBanglaPostKar(CUni)
{
if(CUni == 'া' || CUni=='ো'
|| CUni=='ৌ' || CUni=='ৗ' || CUni=='ু'
|| CUni=='ূ' || CUni=='ী'
|| CUni=='ৃ')
return true;
return false;
} // end function IsBanglaPostKar
/******************************************
Determines whether the unicode
character is a bangla kar
character or not. Its a super
set or Pre and Post kars.
\param CUni The Unicode character
Coded by : S M Mahbub Murshed
Date: August 28, 2006
*******************************************/
function IsBanglaKar(CUni)
{
if(IsBanglaPreKar(CUni) || IsBanglaPostKar(CUni) )
return true;
return false;
} // end function IsBanglaKar
/******************************************
Determines whether the unicode
character is a bangla banjonborno
character or not.
\param CUni The Unicode character
Coded by : S M Mahbub Murshed
Date: August 28, 2006
*******************************************/
function IsBanglaBanjonborno(CUni)
{
if(CUni=='ক' || CUni=='খ' || CUni=='গ' || CUni=='ঘ' || CUni=='ঙ'
|| CUni=='চ' || CUni=='ছ' || CUni=='জ' || CUni=='ঝ' || CUni=='ঞ'
|| CUni=='ট' || CUni=='ঠ' || CUni=='ড' || CUni=='ঢ' || CUni=='ণ'
|| CUni=='ত' || CUni=='থ' || CUni=='দ' || CUni=='ধ' || CUni=='ন'
|| CUni=='প' || CUni=='ফ' || CUni=='ব' || CUni=='ভ' || CUni=='ম'
|| CUni=='শ' || CUni=='ষ' || CUni=='স' || CUni=='হ'
|| CUni=='য' || CUni=='র' || CUni=='ল' || CUni=='য়'
|| CUni=='ং' || CUni=='ঃ' || CUni=='ঁ'
|| CUni=='ৎ')
return true;
return false;
} // end function IsBanglaBanjonborno
/******************************************
Determines whether the unicode
character is a bangla soroborno
character or not.
\param CUni The Unicode character
Coded by : S M Mahbub Murshed
Date: August 28, 2006
*******************************************/
function IsBanglaSoroborno(CUni)
{
if(CUni == 'অ' || CUni=='আ'
|| CUni=='ই' || CUni=='ঈ'
|| CUni=='উ' || CUni=='ঊ'
|| CUni=='ঋ' || CUni=='ঌ'
|| CUni=='এ' || CUni=='ঐ'
|| CUni=='ও' || CUni=='ঔ' )
return true;
return false;
} // end function IsBanglaSoroborno
/******************************************
Determines whether the unicode
character is a bangla nukta
character or not.
\param CUni The Unicode character
Coded by : S M Mahbub Murshed
Date: August 28, 2006
*******************************************/
function IsBanglaNukta(CUni)
{
if(CUni=='ং' || CUni=='ঃ' || CUni=='ঁ')
return true;
return false;
} // end function IsBanglaNukta
/******************************************
Determines whether the unicode
character is a bangla ja fola or ra fola
character or not.
\param CUni The Unicode string
Coded by : S M Mahbub Murshed
Date: August 30, 2006
*******************************************/
function IsBanglaFola(CUni)
{
if(CUni=="্য" || CUni=="্র")
return true;
return false;
} // end function IsBanglaFola
/******************************************
Determines whether the unicode
character is a bangla halant
character or not.
\param CUni The Unicode character
Coded by : S M Mahbub Murshed
Date: August 28, 2006
*******************************************/
function IsBanglaHalant(CUni)
{
if(CUni=='্')
return true;
return false;
} // end function IsBanglaHalant
/******************************************
Determines whether the unicode
character is a bangla character or not.
\param CUni The Unicode character
Coded by : S M Mahbub Murshed
Date: March 02, 2007
*******************************************/
function IsBangla(CUni)
{
if(IsBanglaDigit(CUni) || IsBanglaKar(CUni) ||
IsBanglaBanjonborno(CUni) || IsBanglaSoroborno(CUni) ||
IsBanglaNukta(CUni) || IsBanglaFola(CUni) || IsBanglaHalant(CUni))
return true;
return false;
} // end function IsBangla
/******************************************
Determines whether the character is
a ASCII character or not.
\param CUni The character
Coded by : S M Mahbub Murshed
Date: March 02, 2007
*******************************************/
function IsASCII(CH)
{
if(CH >= 0 && CH< 128)
return true;
return false;
} // end function IsBangla
/******************************************
Determines whether the
character is a space
character or not.
\param C The character
Coded by : S M Mahbub Murshed
Date: August 28, 2006
*******************************************/
function IsSpace(C)
{
if( C==' ' || C=='\t' || C=='\n'
|| C=='\r')
return true;
return false;
} // end function IsSpace
/******************************************
Maps an unicode character to its
equivalent soroborno
\param CUni The Unicode kar character to map with
Coded by : S M Mahbub Murshed
Date: August 30, 2006
*******************************************/
function MapKarToSorborno(CUni)
{
var CSorborno = '';
if(CUni=='া')
CSorborno = 'আ';
else if(CUni=='ি')
CSorborno = 'ই';
else if(CUni=='ী')
CSorborno = 'ঈ';
else if(CUni=='ু')
CSorborno = 'উ';
else if(CUni=='ূ')
CSorborno = 'ঊ';
else if(CUni=='ৃ')
CSorborno = 'ঋ';
else if(CUni=='ে')
CSorborno = 'এ';
else if(CUni=='ৈ')
CSorborno = 'ঐ';
else if(CUni=='ো')
CSorborno = 'ও';
else if(CUni=="ো")
CSorborno = 'ও';
else if(CUni=='ৌ')
CSorborno = 'ঔ';
else if(CUni=="ৌ")
CSorborno = 'ঔ';
return CSorborno;
} // end function MapKarToSorborno
/******************************************
Maps an unicode soroborono to its
equivalent kar
\param CUni The Unicode sorborno character to map with
Coded by : S M Mahbub Murshed
Date: August 30, 2006
*******************************************/
function MapSorbornoToKar(CUni)
{
var CKar = '';
if(CUni=='আ')
CKar = 'া';
else if(CUni=='ই')
CKar = 'ি';
else if(CUni=='ঈ')
CKar = 'ী';
else if(CUni=='উ')
CKar = 'ু';
else if(CUni=='ঊ')
CKar = 'ূ';
else if(CUni=='ঋ')
CKar = 'ৃ';
else if(CUni=='এ')
CKar = 'ে';
else if(CUni=='ঐ')
CKar = 'ৈ';
else if(CUni=='ও')
CKar = 'ো';
else if(CUni=='ঔ')
CKar = 'ৌ';
return CKar;
} // end function MapSorbornoToKar