1 | define(["dojo/_base/lang", "dojo/_base/declare"], |
---|
2 | function(lang,declare){ |
---|
3 | lang.getObject("string", true, dojox); |
---|
4 | |
---|
5 | declare("dojox.string.BidiEngine", null, { |
---|
6 | // summary: |
---|
7 | // This class provides a bidi transformation engine, i.e. |
---|
8 | // functions for reordering and shaping bidi text. |
---|
9 | // description: |
---|
10 | // Bidi stands for support for languages with a bidirectional script. |
---|
11 | // |
---|
12 | // Usually Unicode Bidi Algorithm used by OS platform (and web browsers) is capable of properly transforming |
---|
13 | // Bidi text and as a result it is adequately displayed on the screen. However, in some situations, |
---|
14 | // Unicode Bidi Algorithm is not invoked or is not properly applied. This may occur in situation in which software |
---|
15 | // responsible for rendering the text is not leveraging Unicode Bidi Algorithm implemented by OS (e.g. dojox.GFX renderers). |
---|
16 | // |
---|
17 | // Bidi engine provided in this class implements Unicode Bidi Algorithm as specified at: |
---|
18 | // http://www.unicode.org/reports/tr9/. |
---|
19 | // |
---|
20 | // For more information on basic Bidi concepts please read following article: |
---|
21 | // "Bidirectional script support - A primer" available from: |
---|
22 | // http://www.ibm.com/developerworks/websphere/library/techarticles/bidi/bidigen.html |
---|
23 | // |
---|
24 | // As of February 2011, Bidi engine has following limitations: |
---|
25 | // 1. No support for following numeric shaping options: |
---|
26 | // H - Hindi, |
---|
27 | // C - Contextual, |
---|
28 | // N - Nominal. |
---|
29 | // 2. No support for following shaping options: |
---|
30 | // I - Initial shaping, |
---|
31 | // M - Middle shaping, |
---|
32 | // F - Final shaping, |
---|
33 | // B - Isolated shaping. |
---|
34 | // 3. No support for source-to-target or/and target-to-source maps. |
---|
35 | // 4. No support for LRE/RLE/LRO/RLO/PDF (they are handled like neutrals). |
---|
36 | // 5. No support for Windows compatibility. |
---|
37 | // 6. No support for insert/remove marks. |
---|
38 | // 7. No support for code pages (currently only UTF-8 is supported. Ideally we should convert from any code page to UTF-8). |
---|
39 | |
---|
40 | bidiTransform: function (/*String*/text, /*String*/formatIn, /*String*/formatOut){ |
---|
41 | // summary: |
---|
42 | // Central public API for Bidi engine. Transforms the text according to formatIn, formatOut parameters. |
---|
43 | // If formatIn or formatOut parametrs are not valid throws an exception. |
---|
44 | // inputText: |
---|
45 | // Input text subject to application of Bidi transformation. |
---|
46 | // formatIn: |
---|
47 | // Input Bidi layout in which inputText is passed to the function. |
---|
48 | // formatOut: |
---|
49 | // Output Bidi layout to which inputText should be transformed. |
---|
50 | // description: |
---|
51 | // Both formatIn and formatOut parameters are 5 letters long strings. |
---|
52 | // For example - "ILYNN". Each letter is associated with specific attribute of Bidi layout. |
---|
53 | // Possible and default values for each one of the letters are provided below: |
---|
54 | // |
---|
55 | // First letter: |
---|
56 | // Letter position/index: |
---|
57 | // 1 |
---|
58 | // Letter meaning: |
---|
59 | // Ordering Schema. |
---|
60 | // Possible values: |
---|
61 | // I - Implicit (Logical). |
---|
62 | // V - Visual. |
---|
63 | // Default value: |
---|
64 | // I |
---|
65 | // |
---|
66 | // Second letter: |
---|
67 | // Letter position/index: |
---|
68 | // 2 |
---|
69 | // Letter meaning: |
---|
70 | // Orientation. |
---|
71 | // Possible values: |
---|
72 | // L - Left To Right. |
---|
73 | // R - Right To Left. |
---|
74 | // C - Contextual Left to Right. |
---|
75 | // D - Contextual Right to Left. |
---|
76 | // Default value: |
---|
77 | // L |
---|
78 | // |
---|
79 | // Third letter: |
---|
80 | // Letter position/index: |
---|
81 | // 3 |
---|
82 | // Letter meaning: |
---|
83 | // Symmetric Swapping. |
---|
84 | // Possible values: |
---|
85 | // Y - Symmetric swapping is on. |
---|
86 | // N - Symmetric swapping is off. |
---|
87 | // Default value: |
---|
88 | // Y |
---|
89 | // |
---|
90 | // Fourth letter: |
---|
91 | // Letter position/index: |
---|
92 | // 4 |
---|
93 | // Letter meaning: |
---|
94 | // Shaping. |
---|
95 | // Possible values: |
---|
96 | // S - Text is shaped. |
---|
97 | // N - Text is not shaped. |
---|
98 | // Default value: |
---|
99 | // N |
---|
100 | // |
---|
101 | // Fifth letter: |
---|
102 | // Letter position/index: |
---|
103 | // 5 |
---|
104 | // Letter meaning: |
---|
105 | // Numeric Shaping. |
---|
106 | // Possible values: |
---|
107 | // N - Nominal. |
---|
108 | // Default value: |
---|
109 | // N |
---|
110 | // |
---|
111 | // The output of this function is original text (passed via first argument) transformed from input Bidi layout (second argument) |
---|
112 | // to output Bidi layout (last argument). |
---|
113 | // |
---|
114 | // Sample call: |
---|
115 | // | mytext = bidiTransform("HELLO WORLD", "ILYNN", "VLYNN"); |
---|
116 | // In this case, "HELLO WORLD" text is transformed from Logical - LTR to Visual - LTR Bidi layout with |
---|
117 | // default values for symmetric swapping (Yes), shaping (Not shaped) and numeric shaping (Nominal). |
---|
118 | // returns: /*String*/ or throws an exception. |
---|
119 | // Original text transformed from input Bidi layout (second argument) |
---|
120 | // to output Bidi layout (last argument). |
---|
121 | // Throws an exception if the bidi layout strings are not valid. |
---|
122 | // tags: |
---|
123 | // public |
---|
124 | |
---|
125 | if(!text){ |
---|
126 | return ''; |
---|
127 | } |
---|
128 | if(!formatIn && !formatOut){ |
---|
129 | return text; |
---|
130 | } |
---|
131 | |
---|
132 | // regex for format validation |
---|
133 | // Allowed values for format string are: |
---|
134 | // 1st letter- I, V |
---|
135 | // 2nd letter- L, R, C, D |
---|
136 | // 3rd letter- Y, N |
---|
137 | // 4th letter- S, N |
---|
138 | // 5th letter- N |
---|
139 | var validFormat = /^[(I|V)][(L|R|C|D)][(Y|N)][(S|N)][N]$/; |
---|
140 | if(!validFormat.test(formatIn) || !validFormat.test(formatOut)){ |
---|
141 | throw new Error("dojox.string.BidiEngine: the bidi layout string is wrong!"); |
---|
142 | } |
---|
143 | |
---|
144 | if(formatIn == formatOut){ |
---|
145 | return text; |
---|
146 | } |
---|
147 | |
---|
148 | var orientIn = getOrientation(formatIn.charAt(1)) |
---|
149 | , orientOut = getOrientation(formatOut.charAt(1)) |
---|
150 | , os_in = (formatIn.charAt(0) == 'I') ? 'L' : formatIn.charAt(0) |
---|
151 | , os_out = (formatOut.charAt(0) == 'I') ? 'L' : formatOut.charAt(0) |
---|
152 | , inFormat = os_in + orientIn |
---|
153 | , outFormat = os_out + orientOut |
---|
154 | , swap = formatIn.charAt(2) + formatOut.charAt(2) |
---|
155 | ; |
---|
156 | |
---|
157 | if(inFormat){ |
---|
158 | bdx.defInFormat = inFormat; |
---|
159 | } |
---|
160 | if(outFormat){ |
---|
161 | bdx.defOutFormat = outFormat; |
---|
162 | } |
---|
163 | if(swap){ |
---|
164 | bdx.defSwap = swap; |
---|
165 | } |
---|
166 | |
---|
167 | var stage1_text = doBidiReorder(text, os_in + orientIn, os_out + orientOut, formatIn.charAt(2) + formatOut.charAt(2)) |
---|
168 | , isRtl = false; |
---|
169 | |
---|
170 | if(formatOut.charAt(1) == 'R'){ |
---|
171 | isRtl = true; |
---|
172 | }else if(formatOut.charAt(1) == 'C' || formatOut.charAt(1) == 'D'){ |
---|
173 | isRtl = this.checkContextual(stage1_text); |
---|
174 | } |
---|
175 | if(formatIn.charAt(3) == formatOut.charAt(3)){ |
---|
176 | return stage1_text; |
---|
177 | }else if(formatOut.charAt(3) == 'S'){ |
---|
178 | return shape(isRtl, stage1_text, true); |
---|
179 | } |
---|
180 | if(formatOut.charAt(3) == 'N'){ |
---|
181 | return deshape(stage1_text, isRtl, true); |
---|
182 | } |
---|
183 | }, |
---|
184 | checkContextual: function(/*String*/text){ |
---|
185 | // summary: |
---|
186 | // Determine the base direction of a bidi text according |
---|
187 | // to its first strong directional character. |
---|
188 | // text: |
---|
189 | // The text to check. |
---|
190 | // returns: /*String*/ |
---|
191 | // "ltr" or "rtl" according to the first strong character. |
---|
192 | // If there is no strong character, returns the value of the |
---|
193 | // document dir property. |
---|
194 | // tags: |
---|
195 | // public |
---|
196 | var dir = firstStrongDir(text); |
---|
197 | if(dir != "ltr" && dir != "rtl"){ |
---|
198 | dir = document.dir.toLowerCase(); |
---|
199 | if(dir != "ltr" && dir != "rtl"){dir = "ltr";} |
---|
200 | } |
---|
201 | return dir; |
---|
202 | }, |
---|
203 | hasBidiChar: function(/*String*/text){ |
---|
204 | // summary: |
---|
205 | // Return true if text contains RTL directed character. |
---|
206 | // text: |
---|
207 | // The source string. |
---|
208 | // description: |
---|
209 | // Iterates over the text string, letter by letter starting from its beginning, |
---|
210 | // searching for RTL directed character. |
---|
211 | // Return true if found else false. Needed for vml transformation. |
---|
212 | // returns: /*Boolean*/ |
---|
213 | // true - if text has a RTL directed character. |
---|
214 | // false - otherwise. |
---|
215 | // tags: |
---|
216 | // public |
---|
217 | |
---|
218 | var type = null, uc = null, hi = null; |
---|
219 | for(var i = 0; i < text.length; i++){ |
---|
220 | uc = text.charAt(i).charCodeAt(0); |
---|
221 | hi = MasterTable[uc >> 8]; |
---|
222 | type = hi < TBBASE ? hi : UnicodeTable[hi - TBBASE][uc & 0xFF]; |
---|
223 | if(type == UBAT_R || type == UBAT_AL){ |
---|
224 | return true; |
---|
225 | } |
---|
226 | if(type == UBAT_B){ |
---|
227 | break; |
---|
228 | } |
---|
229 | } |
---|
230 | return false; |
---|
231 | } |
---|
232 | |
---|
233 | }); |
---|
234 | |
---|
235 | |
---|
236 | function doBidiReorder(/*String*/text, /*String*/inFormat, |
---|
237 | /*String*/outFormat, /*String*/swap){ |
---|
238 | // summary: |
---|
239 | // Reorder the source text according to the bidi attributes |
---|
240 | // of source and result. |
---|
241 | // text: |
---|
242 | // The text to reorder. |
---|
243 | // inFormat: |
---|
244 | // Ordering scheme and base direction of the source text. |
---|
245 | // Can be "LLTR", "LRTL", "LCLR", "LCRL", "VLTR", "VRTL", |
---|
246 | // "VCLR", "VCRL". |
---|
247 | // The first letter is "L" for logical ordering scheme, |
---|
248 | // "V" for visual ordering scheme. |
---|
249 | // The other letters specify the base direction. |
---|
250 | // "CLR" means contextual direction defaulting to LTR if |
---|
251 | // there is no strong letter. |
---|
252 | // "CRL" means contextual direction defaulting to RTL if |
---|
253 | // there is no strong letter. |
---|
254 | // The initial value is "LLTR", if none, the initial value is used. |
---|
255 | // outFormat: |
---|
256 | // Required ordering scheme and base direction of the |
---|
257 | // result. Has the same format as inFormat. |
---|
258 | // If none, the initial value "VLTR" is used. |
---|
259 | // swap: |
---|
260 | // Symmetric swapping attributes of source and result. |
---|
261 | // The allowed values can be "YN", "NY", "YY" and "NN". |
---|
262 | // The first letter reflects the symmetric swapping attribute |
---|
263 | // of the source, the second letter that of the result. |
---|
264 | // returns: |
---|
265 | // Text reordered according to source and result attributes. |
---|
266 | |
---|
267 | if(inFormat == undefined){ |
---|
268 | inFormat = bdx.defInFormat; |
---|
269 | } |
---|
270 | if(outFormat == undefined){ |
---|
271 | outFormat = bdx.defOutFormat; |
---|
272 | } |
---|
273 | if(swap == undefined){ |
---|
274 | swap = bdx.defSwap; |
---|
275 | } |
---|
276 | if(inFormat == outFormat){ |
---|
277 | return text; |
---|
278 | } |
---|
279 | var dir, inOrdering = inFormat.substring(0,1) |
---|
280 | , inOrientation = inFormat.substring(1,4) |
---|
281 | , outOrdering = outFormat.substring(0,1) |
---|
282 | , outOrientation = outFormat.substring(1,4) |
---|
283 | ; |
---|
284 | if(inOrientation.charAt(0) == "C"){ |
---|
285 | dir = firstStrongDir(text); |
---|
286 | if(dir == "ltr" || dir == "rtl"){ |
---|
287 | inOrientation = dir.toUpperCase(); |
---|
288 | }else{ |
---|
289 | inOrientation = inFormat.charAt(2) == "L" ? "LTR" : "RTL"; |
---|
290 | } |
---|
291 | inFormat = inOrdering + inOrientation; |
---|
292 | } |
---|
293 | if(outOrientation.charAt(0) == "C"){ |
---|
294 | dir = firstStrongDir(text); |
---|
295 | if(dir == "rtl"){ |
---|
296 | outOrientation = "RTL"; |
---|
297 | }else if(dir == "ltr"){ |
---|
298 | dir = lastStrongDir(text); |
---|
299 | outOrientation = dir.toUpperCase(); |
---|
300 | }else{ |
---|
301 | outOrientation = outFormat.charAt(2) == "L" ? "LTR" : "RTL"; |
---|
302 | } |
---|
303 | outFormat = outOrdering + outOrientation; |
---|
304 | } |
---|
305 | if(inFormat == outFormat){ |
---|
306 | return text; |
---|
307 | } |
---|
308 | bdx.inFormat = inFormat; |
---|
309 | bdx.outFormat = outFormat; |
---|
310 | bdx.swap = swap; |
---|
311 | if((inOrdering == "L") && (outFormat == "VLTR")){ //core cases |
---|
312 | //cases: LLTR->VLTR, LRTL->VLTR |
---|
313 | if(inOrientation == "LTR"){ |
---|
314 | bdx.dir = LTR; |
---|
315 | return doReorder(text); |
---|
316 | } |
---|
317 | if(inOrientation == "RTL"){ |
---|
318 | bdx.dir = RTL; |
---|
319 | return doReorder(text); |
---|
320 | } |
---|
321 | } |
---|
322 | if((inOrdering == "V") && (outOrdering == "V")){ |
---|
323 | //inOrientation != outOrientation |
---|
324 | //cases: VRTL->VLTR, VLTR->VRTL |
---|
325 | return invertStr(text); |
---|
326 | } |
---|
327 | if((inOrdering == "L") && (outFormat == "VRTL")){ |
---|
328 | //cases: LLTR->VRTL, LRTL->VRTL |
---|
329 | if(inOrientation == "LTR"){ |
---|
330 | bdx.dir = LTR; |
---|
331 | text = doReorder(text); |
---|
332 | }else{ |
---|
333 | //inOrientation == RTL |
---|
334 | bdx.dir = RTL; |
---|
335 | text = doReorder(text); |
---|
336 | } |
---|
337 | return invertStr(text); |
---|
338 | } |
---|
339 | if((inFormat == "VLTR") && (outFormat == "LLTR")){ |
---|
340 | //case: VLTR->LLTR |
---|
341 | bdx.dir = LTR; |
---|
342 | return doReorder(text); |
---|
343 | } |
---|
344 | if((inOrdering == "V") && (outOrdering == "L") && (inOrientation != outOrientation)){ |
---|
345 | //cases: VLTR->LRTL, VRTL->LLTR |
---|
346 | text = invertStr(text); |
---|
347 | |
---|
348 | return (inOrientation == "RTL") ? doBidiReorder(text, "LLTR","VLTR", swap) : doBidiReorder(text, "LRTL","VRTL", swap); |
---|
349 | } |
---|
350 | if((inFormat == "VRTL") && (outFormat == "LRTL")){ |
---|
351 | //case VRTL->LRTL |
---|
352 | return doBidiReorder(text, "LRTL","VRTL", swap); |
---|
353 | } |
---|
354 | if((inOrdering == "L") && (outOrdering == "L")){ |
---|
355 | //inOrientation != outOrientation |
---|
356 | //cases: LRTL->LLTR, LLTR->LRTL |
---|
357 | var saveSwap = bdx.swap; |
---|
358 | bdx.swap = saveSwap.substr(0, 1) + "N"; |
---|
359 | if(inOrientation == "RTL"){ |
---|
360 | //LRTL->LLTR |
---|
361 | bdx.dir = RTL; |
---|
362 | text = doReorder(text); |
---|
363 | bdx.swap = "N" + saveSwap.substr(1, 2); |
---|
364 | bdx.dir = LTR; |
---|
365 | text = doReorder(text); |
---|
366 | }else{ //LLTR->LRTL |
---|
367 | bdx.dir = LTR; |
---|
368 | text = doReorder(text); |
---|
369 | bdx.swap = "N" + saveSwap.substr(1, 2); |
---|
370 | text = doBidiReorder(text, "VLTR","LRTL", bdx.swap); |
---|
371 | } |
---|
372 | return text; |
---|
373 | } |
---|
374 | |
---|
375 | }; |
---|
376 | |
---|
377 | function shape(/*boolean*/rtl, /*String*/text, /*boolean*/compress){ |
---|
378 | // summary: |
---|
379 | // Shape the source text. |
---|
380 | // rtl: |
---|
381 | // Flag indicating if the text is in RTL direction (logical |
---|
382 | // direction for Arabic words). |
---|
383 | // text: |
---|
384 | // The text to shape. |
---|
385 | // compress: |
---|
386 | // A flag indicates to insert extra space after the lam alef compression |
---|
387 | // to preserve the buffer size or not insert an extra space which will lead |
---|
388 | // to decrease the buffer size. this option can be: |
---|
389 | // - true (default) to not insert extra space after compressing Lam+Alef into one character Lamalef |
---|
390 | // - false to insert an extra space after compressed Lamalef to preserve the buffer size |
---|
391 | // returns: |
---|
392 | // text shaped. |
---|
393 | // tags: |
---|
394 | // private. |
---|
395 | |
---|
396 | if(text.length == 0){ |
---|
397 | return; |
---|
398 | } |
---|
399 | if(rtl == undefined){ |
---|
400 | rtl = true; |
---|
401 | } |
---|
402 | if(compress == undefined){ |
---|
403 | compress = true; |
---|
404 | } |
---|
405 | text = new String(text); |
---|
406 | |
---|
407 | var str06 = text.split("") |
---|
408 | , Ix = 0 |
---|
409 | , step = +1 |
---|
410 | , nIEnd = str06.length |
---|
411 | ; |
---|
412 | if(!rtl){ |
---|
413 | Ix = str06.length - 1; |
---|
414 | step = -1; |
---|
415 | nIEnd = 1; |
---|
416 | } |
---|
417 | var previousCursive = 0, compressArray = [], compressArrayIndx = 0; |
---|
418 | for(var index = Ix; index * step < nIEnd; index = index + step){ |
---|
419 | if(isArabicAlefbet(str06[index]) || isArabicDiacritics(str06[index])){ |
---|
420 | // Arabic letter Lam |
---|
421 | if(str06[index] == '\u0644'){ |
---|
422 | if(isNextAlef(str06, (index + step), step, nIEnd)){ |
---|
423 | str06[index] = (previousCursive == 0) ? getLamAlefFE(str06[index + step], LamAlefInialTableFE) : getLamAlefFE(str06[index + step], LamAlefMedialTableFE); |
---|
424 | index += step; |
---|
425 | setAlefToSpace(str06, index, step, nIEnd); |
---|
426 | if(compress){ |
---|
427 | compressArray[compressArrayIndx] = index; |
---|
428 | compressArrayIndx++; |
---|
429 | } |
---|
430 | previousCursive = 0; |
---|
431 | continue; |
---|
432 | } |
---|
433 | } |
---|
434 | var currentChr = str06[index]; |
---|
435 | if(previousCursive == 1){ |
---|
436 | // if next is Arabic |
---|
437 | //Character is in medial form |
---|
438 | // else character is in final form |
---|
439 | str06[index] = (isNextArabic(str06, (index + step), step, nIEnd)) ? |
---|
440 | getMedialFormCharacterFE(str06[index]) : getFormCharacterFE(str06[index], FinalForm); |
---|
441 | }else{ |
---|
442 | if(isNextArabic(str06, (index + step), step, nIEnd) == true){ |
---|
443 | //character is in Initial form |
---|
444 | str06[index] = getFormCharacterFE(str06[index],InitialForm); |
---|
445 | }else{ |
---|
446 | str06[index] = getFormCharacterFE(str06[index], IsolatedForm); |
---|
447 | } |
---|
448 | } |
---|
449 | //exam if the current character is cursive |
---|
450 | if(!isArabicDiacritics(currentChr)){ |
---|
451 | previousCursive = 1; |
---|
452 | } |
---|
453 | if(isStandAlonCharacter(currentChr) == true){ |
---|
454 | previousCursive = 0; |
---|
455 | } |
---|
456 | }else{ |
---|
457 | previousCursive = 0; |
---|
458 | } |
---|
459 | } |
---|
460 | var outBuf = ""; |
---|
461 | for(idx = 0; idx < str06.length; idx++){ |
---|
462 | if(!(compress && indexOf(compressArray, compressArray.length, idx) > -1)){ |
---|
463 | outBuf += str06[idx]; |
---|
464 | } |
---|
465 | } |
---|
466 | return outBuf; |
---|
467 | }; |
---|
468 | function firstStrongDir(/*String*/text){ |
---|
469 | // summary: |
---|
470 | // Return the first strong character direction |
---|
471 | // text: |
---|
472 | // The source string. |
---|
473 | // description: |
---|
474 | // Iterates over the text string, letter by letter starting from its beginning, |
---|
475 | // searching for first "strong" character. |
---|
476 | // Returns if strong character was found with the direction defined by this |
---|
477 | // character, if no strong character was found returns an empty string. |
---|
478 | // returns: /*String*/ |
---|
479 | // "ltr" - if the first strong character is Latin. |
---|
480 | // "rtl" - if the first strong character is RTL directed character. |
---|
481 | // "" - if the strong character wasn't found. |
---|
482 | // tags: |
---|
483 | // private |
---|
484 | |
---|
485 | var type = null, uc = null, hi = null; |
---|
486 | for(var i = 0; i < text.length; i++){ |
---|
487 | uc = text.charAt(i).charCodeAt(0); |
---|
488 | hi = MasterTable[uc >> 8]; |
---|
489 | type = hi < TBBASE ? hi : UnicodeTable[hi - TBBASE][uc & 0xFF]; |
---|
490 | if(type == UBAT_R || type == UBAT_AL){ |
---|
491 | return "rtl"; |
---|
492 | } |
---|
493 | if(type == UBAT_L){ |
---|
494 | return "ltr"; |
---|
495 | } |
---|
496 | if(type == UBAT_B){ |
---|
497 | break; |
---|
498 | } |
---|
499 | } |
---|
500 | return ""; |
---|
501 | }; |
---|
502 | function lastStrongDir(text){ |
---|
503 | // summary: |
---|
504 | // Return the last strong character direction |
---|
505 | // text: |
---|
506 | // The source string. |
---|
507 | // description: |
---|
508 | // Iterates over the text string, letter by letter starting from its end, |
---|
509 | // searching for first (from the end) "strong" character. |
---|
510 | // Returns if strong character was found with the direction defined by this |
---|
511 | // character, if no strong character was found returns an empty string. |
---|
512 | // tags: |
---|
513 | // private |
---|
514 | var type = null; |
---|
515 | for(var i = text.length - 1; i >= 0; i--){ |
---|
516 | type = getCharacterType(text.charAt(i)); |
---|
517 | if(type == UBAT_R || type == UBAT_AL){ |
---|
518 | return "rtl"; |
---|
519 | } |
---|
520 | if(type == UBAT_L){ |
---|
521 | return "ltr"; |
---|
522 | } |
---|
523 | if(type == UBAT_B){ |
---|
524 | break; |
---|
525 | } |
---|
526 | } |
---|
527 | return ""; |
---|
528 | }; |
---|
529 | function deshape(/*String*/text, /*boolean*/rtl, /*boolean*/consume_next_space){ |
---|
530 | // summary: |
---|
531 | // deshape the source text. |
---|
532 | // text: |
---|
533 | // the text to be deshape. |
---|
534 | // rtl: |
---|
535 | // flag indicating if the text is in RTL direction (logical |
---|
536 | // direction for Arabic words). |
---|
537 | // consume_next_space: |
---|
538 | // flag indicating whether to consume the space next to the |
---|
539 | // the lam alef if there is a space followed the Lamalef character to preserve the buffer size. |
---|
540 | // In case there is no space next to the lam alef the buffer size will be increased due to the |
---|
541 | // expansion of the lam alef one character into lam+alef two characters |
---|
542 | // returns: text deshaped. |
---|
543 | if(text.length == 0){ |
---|
544 | return; |
---|
545 | } |
---|
546 | if(consume_next_space == undefined){ |
---|
547 | consume_next_space = true; |
---|
548 | } |
---|
549 | if(rtl == undefined){ |
---|
550 | rtl = true; |
---|
551 | } |
---|
552 | text = new String(text); |
---|
553 | |
---|
554 | var outBuf = "", strFE = [], textBuff = ""; |
---|
555 | if(consume_next_space){ |
---|
556 | for(var j = 0; j < text.length; j++){ |
---|
557 | if(text.charAt(j) == ' '){ |
---|
558 | if(rtl){ |
---|
559 | if(j > 0){ |
---|
560 | if(text.charAt(j - 1) >= '\uFEF5' && text.charAt(j - 1) <= '\uFEFC'){ |
---|
561 | continue; |
---|
562 | } |
---|
563 | } |
---|
564 | }else{ |
---|
565 | if(j+1 < text.length){ |
---|
566 | if(text.charAt(j + 1) >= '\uFEF5' && text.charAt(j + 1) <= '\uFEFC'){ |
---|
567 | continue; |
---|
568 | } |
---|
569 | } |
---|
570 | } |
---|
571 | } |
---|
572 | textBuff += text.charAt(j); |
---|
573 | } |
---|
574 | }else{ |
---|
575 | textBuff = new String(text); |
---|
576 | } |
---|
577 | strFE = textBuff.split(""); |
---|
578 | for(var i = 0; i < textBuff.length; i++){ |
---|
579 | if(strFE[i] >= '\uFE70' && strFE[i] < '\uFEFF'){ |
---|
580 | var chNum = textBuff.charCodeAt(i); |
---|
581 | if(strFE[i] >= '\uFEF5' && strFE[i] <= '\uFEFC'){ |
---|
582 | //expand the LamAlef |
---|
583 | if(rtl){ |
---|
584 | //Lam + Alef |
---|
585 | outBuf += '\u0644'; |
---|
586 | outBuf += AlefTable[parseInt((chNum - 65269) / 2)]; |
---|
587 | }else{ |
---|
588 | outBuf += AlefTable[parseInt((chNum - 65269) / 2)]; |
---|
589 | outBuf += '\u0644'; |
---|
590 | } |
---|
591 | }else{ |
---|
592 | outBuf += FETo06Table[chNum - 65136]; |
---|
593 | } |
---|
594 | }else{ |
---|
595 | outBuf += strFE[i]; |
---|
596 | } |
---|
597 | } |
---|
598 | return outBuf; |
---|
599 | }; |
---|
600 | function doReorder(str){ |
---|
601 | // summary: |
---|
602 | // Helper to the doBidiReorder. Manages the UBA. |
---|
603 | // str: |
---|
604 | // the string to reorder. |
---|
605 | // returns: |
---|
606 | // text reordered according to source and result attributes. |
---|
607 | // tags: |
---|
608 | // private |
---|
609 | var chars = str.split(""), levels = []; |
---|
610 | |
---|
611 | computeLevels(chars, levels); |
---|
612 | swapChars(chars, levels); |
---|
613 | invertLevel(2, chars, levels); |
---|
614 | invertLevel(1, chars, levels); |
---|
615 | return chars.join(""); |
---|
616 | }; |
---|
617 | function computeLevels(chars, levels){ |
---|
618 | var len = chars.length |
---|
619 | , impTab = bdx.dir ? impTab_RTL : impTab_LTR |
---|
620 | , prevState = null, newClass = null, newLevel = null, newState = 0 |
---|
621 | , action = null, cond = null, condPos = -1, i = null, ix = null |
---|
622 | , types = [] |
---|
623 | , classes = [] |
---|
624 | ; |
---|
625 | bdx.hiLevel = bdx.dir; |
---|
626 | bdx.lastArabic = false; |
---|
627 | bdx.hasUBAT_AL = false, |
---|
628 | bdx.hasUBAT_B = false; |
---|
629 | bdx.hasUBAT_S = false; |
---|
630 | for(i = 0; i < len; i++){ |
---|
631 | types[i] = getCharacterType(chars[i]); |
---|
632 | } |
---|
633 | for(ix = 0; ix < len; ix++){ |
---|
634 | prevState = newState; |
---|
635 | classes[ix] = newClass = getCharClass(chars, types, classes, ix); |
---|
636 | newState = impTab[prevState][newClass]; |
---|
637 | action = newState & 0xF0; |
---|
638 | newState &= 0x0F; |
---|
639 | levels[ix] = newLevel = impTab[newState][ITIL]; |
---|
640 | if(action > 0){ |
---|
641 | if(action == 0x10){ // set conditional run to level 1 |
---|
642 | for(i = condPos; i < ix; i++){ |
---|
643 | levels[i] = 1; |
---|
644 | } |
---|
645 | condPos = -1; |
---|
646 | }else{ // 0x20 confirm the conditional run |
---|
647 | condPos = -1; |
---|
648 | } |
---|
649 | } |
---|
650 | cond = impTab[newState][ITCOND]; |
---|
651 | if(cond){ |
---|
652 | if(condPos == -1){ |
---|
653 | condPos = ix; |
---|
654 | } |
---|
655 | }else{ // unconditional level |
---|
656 | if(condPos > -1){ |
---|
657 | for(i = condPos; i < ix; i++){ |
---|
658 | levels[i] = newLevel; |
---|
659 | } |
---|
660 | condPos = -1; |
---|
661 | } |
---|
662 | } |
---|
663 | if(types[ix] == UBAT_B){ |
---|
664 | levels[ix] = 0; |
---|
665 | } |
---|
666 | bdx.hiLevel |= newLevel; |
---|
667 | } |
---|
668 | if(bdx.hasUBAT_S){ |
---|
669 | for(i = 0; i < len; i++){ |
---|
670 | if(types[i] == UBAT_S){ |
---|
671 | levels[i] = bdx.dir; |
---|
672 | for(var j = i - 1; j >= 0; j--){ |
---|
673 | if(types[j] == UBAT_WS){ |
---|
674 | levels[j] = bdx.dir; |
---|
675 | }else{ |
---|
676 | break; |
---|
677 | } |
---|
678 | } |
---|
679 | } |
---|
680 | } |
---|
681 | } |
---|
682 | }; |
---|
683 | function swapChars(chars, levels){ |
---|
684 | // summary: |
---|
685 | // Swap characters with symmetrical mirroring as all kinds of parenthesis. |
---|
686 | // (When needed). |
---|
687 | // chars: |
---|
688 | // The source string as Array of characters. |
---|
689 | // levels: |
---|
690 | // An array (like hash) of flags for each character in the source string, |
---|
691 | // that defines if swapping should be applied on the following character. |
---|
692 | // description: |
---|
693 | // First checks if the swapping should be applied, if not returns, else |
---|
694 | // uses the levels "hash" to find what characters should be swapped. |
---|
695 | // tags: |
---|
696 | // private |
---|
697 | |
---|
698 | if(bdx.hiLevel == 0 || bdx.swap.substr(0, 1) == bdx.swap.substr(1, 2)){ |
---|
699 | return; |
---|
700 | }; |
---|
701 | |
---|
702 | //console.log("bdx.hiLevel == 0: " + bdx.hiLevel + "bdx.swap[0]: "+ bdx.swap[0] +" bdx.swap[1]: " +bdx.swap[1]); |
---|
703 | for(var i = 0; i < chars.length; i++){ |
---|
704 | if(levels[i] == 1){chars[i] = getMirror(chars[i]);} |
---|
705 | } |
---|
706 | }; |
---|
707 | function getCharacterType(ch){ |
---|
708 | // summary: |
---|
709 | // Return the type of the character. |
---|
710 | // ch: |
---|
711 | // The character to be checked. |
---|
712 | |
---|
713 | // description: |
---|
714 | // Check the type of the character according to MasterTable, |
---|
715 | // type = LTR, RTL, neutral,Arabic-Indic digit etc. |
---|
716 | // tags: |
---|
717 | // private |
---|
718 | var uc = ch.charCodeAt(0) |
---|
719 | , hi = MasterTable[uc >> 8]; |
---|
720 | return (hi < TBBASE) ? hi : UnicodeTable[hi - TBBASE][uc & 0xFF]; |
---|
721 | }; |
---|
722 | function invertStr(str){ |
---|
723 | // summary: |
---|
724 | // Return the reversed string. |
---|
725 | // str: |
---|
726 | // The string to be reversed. |
---|
727 | // description: |
---|
728 | // Reverse the string str. |
---|
729 | // tags: |
---|
730 | // private |
---|
731 | var chars = str.split(""); |
---|
732 | chars.reverse(); |
---|
733 | return chars.join(""); |
---|
734 | }; |
---|
735 | function indexOf(cArray, cLength, idx){ |
---|
736 | var counter = -1; |
---|
737 | for(var i = 0; i < cLength; i++){ |
---|
738 | if(cArray[i] == idx){ |
---|
739 | return i; |
---|
740 | } |
---|
741 | } |
---|
742 | return -1; |
---|
743 | }; |
---|
744 | function isArabicAlefbet(c){ |
---|
745 | for(var i = 0; i < ArabicAlefBetIntervalsBegine.length; i++){ |
---|
746 | if(c >= ArabicAlefBetIntervalsBegine[i] && c <= ArabicAlefBetIntervalsEnd[i]){ |
---|
747 | return true; |
---|
748 | } |
---|
749 | } |
---|
750 | return false; |
---|
751 | }; |
---|
752 | function isNextArabic(str06, index, step, nIEnd){ |
---|
753 | while(((index) * step) < nIEnd && isArabicDiacritics(str06[index])){ |
---|
754 | index += step; |
---|
755 | } |
---|
756 | if(((index) * step) < nIEnd && isArabicAlefbet(str06[index])){ |
---|
757 | return true; |
---|
758 | } |
---|
759 | return false; |
---|
760 | }; |
---|
761 | function isNextAlef(str06, index, step, nIEnd){ |
---|
762 | while(((index) * step) < nIEnd && isArabicDiacritics(str06[index])){ |
---|
763 | index += step; |
---|
764 | } |
---|
765 | var c = ' '; |
---|
766 | if(((index) * step) < nIEnd){ |
---|
767 | c = str06[index]; |
---|
768 | }else{ |
---|
769 | return false; |
---|
770 | } |
---|
771 | for(var i = 0; i < AlefTable.length; i++){ |
---|
772 | if(AlefTable[i] == c){ |
---|
773 | return true; |
---|
774 | } |
---|
775 | } |
---|
776 | return false; |
---|
777 | }; |
---|
778 | function invertLevel(lev, chars, levels){ |
---|
779 | if(bdx.hiLevel < lev){ |
---|
780 | return; |
---|
781 | } |
---|
782 | if(lev == 1 && bdx.dir == RTL && !bdx.hasUBAT_B){ |
---|
783 | chars.reverse(); |
---|
784 | return; |
---|
785 | } |
---|
786 | var len = chars.length, start = 0, end, lo, hi, tmp; |
---|
787 | while(start < len){ |
---|
788 | if(levels[start] >= lev){ |
---|
789 | end = start + 1; |
---|
790 | while(end < len && levels[end] >= lev){ |
---|
791 | end++; |
---|
792 | } |
---|
793 | for(lo = start, hi = end - 1 ; lo < hi; lo++, hi--){ |
---|
794 | tmp = chars[lo]; |
---|
795 | chars[lo] = chars[hi]; |
---|
796 | chars[hi] = tmp; |
---|
797 | } |
---|
798 | start = end; |
---|
799 | } |
---|
800 | start++; |
---|
801 | } |
---|
802 | }; |
---|
803 | function getCharClass(chars, types, classes, ix){ |
---|
804 | // summary: |
---|
805 | // Return the class if ix character in chars. |
---|
806 | // chars: |
---|
807 | // The source string as Array of characters. |
---|
808 | // types: |
---|
809 | // Array of types, for each character in chars. |
---|
810 | // classes: |
---|
811 | // Array of classes that already been solved. |
---|
812 | // ix: |
---|
813 | // the index of checked character. |
---|
814 | // tags: |
---|
815 | // private |
---|
816 | var cType = types[ix], wType, nType, len, i; |
---|
817 | switch(cType){ |
---|
818 | case UBAT_L: |
---|
819 | case UBAT_R: |
---|
820 | bdx.lastArabic = false; |
---|
821 | case UBAT_ON: |
---|
822 | case UBAT_AN: |
---|
823 | return cType; |
---|
824 | case UBAT_EN: |
---|
825 | return bdx.lastArabic ? UBAT_AN : UBAT_EN; |
---|
826 | case UBAT_AL: |
---|
827 | bdx.lastArabic = true; |
---|
828 | bdx.hasUBAT_AL = true; |
---|
829 | return UBAT_R; |
---|
830 | case UBAT_WS: |
---|
831 | return UBAT_ON; |
---|
832 | case UBAT_CS: |
---|
833 | if(ix < 1 || (ix + 1) >= types.length || |
---|
834 | ((wType = classes[ix - 1]) != UBAT_EN && wType != UBAT_AN) || |
---|
835 | ((nType = types[ix + 1]) != UBAT_EN && nType != UBAT_AN)){ |
---|
836 | return UBAT_ON; |
---|
837 | } |
---|
838 | if(bdx.lastArabic){nType = UBAT_AN;} |
---|
839 | return nType == wType ? nType : UBAT_ON; |
---|
840 | case UBAT_ES: |
---|
841 | wType = ix > 0 ? classes[ix - 1] : UBAT_B; |
---|
842 | if(wType == UBAT_EN && (ix + 1) < types.length && types[ix + 1] == UBAT_EN){ |
---|
843 | return UBAT_EN; |
---|
844 | } |
---|
845 | return UBAT_ON; |
---|
846 | case UBAT_ET: |
---|
847 | if(ix > 0 && classes[ix - 1] == UBAT_EN){ |
---|
848 | return UBAT_EN; |
---|
849 | } |
---|
850 | if(bdx.lastArabic){ |
---|
851 | return UBAT_ON; |
---|
852 | } |
---|
853 | i = ix + 1; |
---|
854 | len = types.length; |
---|
855 | while(i < len && types[i] == UBAT_ET){ |
---|
856 | i++; |
---|
857 | } |
---|
858 | if(i < len && types[i] == UBAT_EN){ |
---|
859 | return UBAT_EN; |
---|
860 | } |
---|
861 | return UBAT_ON; |
---|
862 | case UBAT_NSM: |
---|
863 | if(bdx.inFormat == "VLTR"){ // visual to implicit transformation |
---|
864 | len = types.length; |
---|
865 | i = ix + 1; |
---|
866 | while(i < len && types[i] == UBAT_NSM){ |
---|
867 | i++; |
---|
868 | } |
---|
869 | if(i < len){ |
---|
870 | var c = chars[ix] |
---|
871 | , rtlCandidate = (c >= 0x0591 && c <= 0x08FF) || c == 0xFB1E |
---|
872 | ; |
---|
873 | wType = types[i]; |
---|
874 | if(rtlCandidate && (wType == UBAT_R || wType == UBAT_AL)){ |
---|
875 | return UBAT_R; |
---|
876 | } |
---|
877 | } |
---|
878 | } |
---|
879 | if(ix < 1 || (wType = types[ix - 1]) == UBAT_B){ |
---|
880 | return UBAT_ON; |
---|
881 | } |
---|
882 | return classes[ix - 1]; |
---|
883 | case UBAT_B: |
---|
884 | lastArabic = false; |
---|
885 | bdx.hasUBAT_B = true; |
---|
886 | return bdx.dir; |
---|
887 | case UBAT_S: |
---|
888 | bdx.hasUBAT_S = true; |
---|
889 | return UBAT_ON; |
---|
890 | case UBAT_LRE: |
---|
891 | case UBAT_RLE: |
---|
892 | case UBAT_LRO: |
---|
893 | case UBAT_RLO: |
---|
894 | case UBAT_PDF: |
---|
895 | lastArabic = false; |
---|
896 | case UBAT_BN: |
---|
897 | return UBAT_ON; |
---|
898 | } |
---|
899 | }; |
---|
900 | function getMirror(c){ |
---|
901 | // summary: |
---|
902 | // Calculates the mirrored character of c |
---|
903 | // c: |
---|
904 | // The character to be mirrored. |
---|
905 | // tags: |
---|
906 | // private |
---|
907 | var mid, low = 0, high = SwapTable.length - 1; |
---|
908 | |
---|
909 | while(low <= high){ |
---|
910 | mid = Math.floor((low + high) / 2); |
---|
911 | if(c < SwapTable[mid][0]){ |
---|
912 | high = mid - 1; |
---|
913 | }else if(c > SwapTable[mid][0]){ |
---|
914 | low = mid + 1; |
---|
915 | }else{ |
---|
916 | return SwapTable[mid][1]; |
---|
917 | } |
---|
918 | } |
---|
919 | return c; |
---|
920 | }; |
---|
921 | function isStandAlonCharacter(c){ |
---|
922 | for(var i = 0; i < StandAlonForm.length; i++){ |
---|
923 | if(StandAlonForm[i] == c){ |
---|
924 | return true; |
---|
925 | } |
---|
926 | } |
---|
927 | return false; |
---|
928 | }; |
---|
929 | function getMedialFormCharacterFE(c){ |
---|
930 | for(var i = 0; i < BaseForm.length; i++){ |
---|
931 | if(c == BaseForm[i]){ |
---|
932 | return MedialForm[i]; |
---|
933 | } |
---|
934 | } |
---|
935 | return c; |
---|
936 | }; |
---|
937 | function getFormCharacterFE(/*char*/ c, /*char[]*/formArr){ |
---|
938 | for(var i = 0; i < BaseForm.length; i++){ |
---|
939 | if(c == BaseForm[i]){ |
---|
940 | return formArr[i]; |
---|
941 | } |
---|
942 | } |
---|
943 | return c; |
---|
944 | }; |
---|
945 | function isArabicDiacritics(c){ |
---|
946 | return (c >= '\u064b' && c <= '\u0655') ? true : false; |
---|
947 | }; |
---|
948 | function getOrientation(/*Char*/ oc){ |
---|
949 | if(oc == 'L'){ |
---|
950 | return "LTR"; |
---|
951 | } |
---|
952 | if(oc == 'R'){ |
---|
953 | return "RTL"; |
---|
954 | } |
---|
955 | if(oc == 'C'){ |
---|
956 | return "CLR"; |
---|
957 | } |
---|
958 | if(oc == 'D'){ |
---|
959 | return "CRL"; |
---|
960 | } |
---|
961 | }; |
---|
962 | function setAlefToSpace(str06, index, step, nIEnd){ |
---|
963 | while(((index) * step) < nIEnd && isArabicDiacritics(str06[index])){ |
---|
964 | index += step; |
---|
965 | } |
---|
966 | if(((index) * step) < nIEnd){ |
---|
967 | str06[index] = ' '; |
---|
968 | return true; |
---|
969 | } |
---|
970 | return false; |
---|
971 | }; |
---|
972 | function getLamAlefFE(alef06, LamAlefForm){ |
---|
973 | for(var i = 0; i < AlefTable.length; i++){ |
---|
974 | if(alef06 == AlefTable[i]){ |
---|
975 | return LamAlefForm[i]; |
---|
976 | } |
---|
977 | } |
---|
978 | return alef06; |
---|
979 | }; |
---|
980 | function LamAlef(alef){ |
---|
981 | // summary: |
---|
982 | // If the alef variable is an ARABIC ALEF letter, |
---|
983 | // return the LamAlef code associated with the specific |
---|
984 | // alef character. |
---|
985 | // alef: |
---|
986 | // The alef code type. |
---|
987 | // description: |
---|
988 | // If "alef" is an ARABIC ALEF letter, identify which alef is it, |
---|
989 | // using AlefTable, then return the LamAlef associated with it. |
---|
990 | // tags: |
---|
991 | // private |
---|
992 | for(var i = 0; i < AlefTable.length; i++){ |
---|
993 | if(AlefTable[i] == alef){ |
---|
994 | return AlefTable[i]; |
---|
995 | } |
---|
996 | } |
---|
997 | return 0; |
---|
998 | }; |
---|
999 | |
---|
1000 | var bdx = { |
---|
1001 | dir: 0, |
---|
1002 | defInFormat: "LLTR", |
---|
1003 | defoutFormat: "VLTR", |
---|
1004 | defSwap: "YN", |
---|
1005 | inFormat: "LLTR", |
---|
1006 | outFormat: "VLTR", |
---|
1007 | swap: "YN", |
---|
1008 | hiLevel: 0, |
---|
1009 | lastArabic: false, |
---|
1010 | hasUBAT_AL: false, |
---|
1011 | hasBlockSep: false, |
---|
1012 | hasSegSep: false |
---|
1013 | }; |
---|
1014 | |
---|
1015 | var ITIL = 5; |
---|
1016 | |
---|
1017 | var ITCOND = 6; |
---|
1018 | |
---|
1019 | var LTR = 0; |
---|
1020 | |
---|
1021 | var RTL = 1; |
---|
1022 | |
---|
1023 | /****************************************************************************/ |
---|
1024 | /* Array in which directional characters are replaced by their symmetric. */ |
---|
1025 | /****************************************************************************/ |
---|
1026 | var SwapTable = [ |
---|
1027 | [ "\u0028", "\u0029" ], /* Round brackets */ |
---|
1028 | [ "\u0029", "\u0028" ], |
---|
1029 | [ "\u003C", "\u003E" ], /* Less than/greater than */ |
---|
1030 | [ "\u003E", "\u003C" ], |
---|
1031 | [ "\u005B", "\u005D" ], /* Square brackets */ |
---|
1032 | [ "\u005D", "\u005B" ], |
---|
1033 | [ "\u007B", "\u007D" ], /* Curly brackets */ |
---|
1034 | [ "\u007D", "\u007B" ], |
---|
1035 | [ "\u00AB", "\u00BB" ], /* Double angle quotation marks */ |
---|
1036 | [ "\u00BB", "\u00AB" ], |
---|
1037 | [ "\u2039", "\u203A" ], /* single angle quotation mark */ |
---|
1038 | [ "\u203A", "\u2039" ], |
---|
1039 | [ "\u207D", "\u207E" ], /* Superscript parentheses */ |
---|
1040 | [ "\u207E", "\u207D" ], |
---|
1041 | [ "\u208D", "\u208E" ], /* Subscript parentheses */ |
---|
1042 | [ "\u208E", "\u208D" ], |
---|
1043 | [ "\u2264", "\u2265" ], /* Less/greater than or equal */ |
---|
1044 | [ "\u2265", "\u2264" ], |
---|
1045 | [ "\u2329", "\u232A" ], /* Angle brackets */ |
---|
1046 | [ "\u232A", "\u2329" ], |
---|
1047 | [ "\uFE59", "\uFE5A" ], /* Small round brackets */ |
---|
1048 | [ "\uFE5A", "\uFE59" ], |
---|
1049 | [ "\uFE5B", "\uFE5C" ], /* Small curly brackets */ |
---|
1050 | [ "\uFE5C", "\uFE5B" ], |
---|
1051 | [ "\uFE5D", "\uFE5E" ], /* Small tortoise shell brackets */ |
---|
1052 | [ "\uFE5E", "\uFE5D" ], |
---|
1053 | [ "\uFE64", "\uFE65" ], /* Small less than/greater than */ |
---|
1054 | [ "\uFE65", "\uFE64" ] |
---|
1055 | ]; |
---|
1056 | var AlefTable = ['\u0622', '\u0623', '\u0625', '\u0627']; |
---|
1057 | |
---|
1058 | var AlefTableFE = [0xFE81, 0xFE82, 0xFE83, 0xFE84, 0xFE87, 0xFE88, 0xFE8D, 0xFE8E]; |
---|
1059 | |
---|
1060 | var LamTableFE = [0xFEDD, 0xFEDE, 0xFEDF, 0xFEE0]; |
---|
1061 | |
---|
1062 | var LamAlefInialTableFE = ['\ufef5', '\ufef7', '\ufef9', '\ufefb']; |
---|
1063 | |
---|
1064 | var LamAlefMedialTableFE = ['\ufef6', '\ufef8', '\ufefa', '\ufefc']; |
---|
1065 | /** |
---|
1066 | * Arabic Characters in the base form |
---|
1067 | */ |
---|
1068 | var BaseForm = ['\u0627', '\u0628', '\u062A', '\u062B', '\u062C', '\u062D', '\u062E', '\u062F', '\u0630', '\u0631', '\u0632', '\u0633', '\u0634', '\u0635', '\u0636', '\u0637', '\u0638', '\u0639', '\u063A', '\u0641', '\u0642', '\u0643', '\u0644', '\u0645', '\u0646', '\u0647', '\u0648', '\u064A', '\u0625', '\u0623', '\u0622', '\u0629', '\u0649', '\u06CC', '\u0626', '\u0624', '\u064B', '\u064C', '\u064D', '\u064E', '\u064F', '\u0650', '\u0651', '\u0652', '\u0621']; |
---|
1069 | |
---|
1070 | /** |
---|
1071 | * Arabic shaped characters in Isolated form |
---|
1072 | */ |
---|
1073 | var IsolatedForm = ['\uFE8D', '\uFE8F', '\uFE95', '\uFE99', '\uFE9D', '\uFEA1', '\uFEA5', '\uFEA9', '\uFEAB', '\uFEAD', '\uFEAF', '\uFEB1', '\uFEB5', '\uFEB9', '\uFEBD', '\uFEC1', '\uFEC5', '\uFEC9', '\uFECD', '\uFED1', '\uFED5', '\uFED9', '\uFEDD', '\uFEE1', '\uFEE5', '\uFEE9', '\uFEED', '\uFEF1', '\uFE87', '\uFE83', '\uFE81', '\uFE93', '\uFEEF', '\uFBFC', '\uFE89', '\uFE85', '\uFE70', '\uFE72', '\uFE74', '\uFE76', '\uFE78', '\uFE7A', '\uFE7C', '\uFE7E', '\uFE80']; |
---|
1074 | |
---|
1075 | /** |
---|
1076 | * Arabic shaped characters in Final form |
---|
1077 | */ |
---|
1078 | var FinalForm = ['\uFE8E', '\uFE90', '\uFE96', '\uFE9A', '\uFE9E', '\uFEA2', '\uFEA6', '\uFEAA', '\uFEAC', '\uFEAE', '\uFEB0', '\uFEB2', '\uFEB6', '\uFEBA', '\uFEBE', '\uFEC2', '\uFEC6', '\uFECA', '\uFECE', '\uFED2', '\uFED6', '\uFEDA', '\uFEDE', '\uFEE2', '\uFEE6', '\uFEEA', '\uFEEE', '\uFEF2', '\uFE88', '\uFE84', '\uFE82', '\uFE94', '\uFEF0', '\uFBFD', '\uFE8A', '\uFE86', '\uFE70', '\uFE72', '\uFE74', '\uFE76', '\uFE78', '\uFE7A', '\uFE7C', '\uFE7E', '\uFE80']; |
---|
1079 | |
---|
1080 | /** |
---|
1081 | * Arabic shaped characters in Media form |
---|
1082 | */ |
---|
1083 | var MedialForm = ['\uFE8E', '\uFE92', '\uFE98', '\uFE9C', '\uFEA0', '\uFEA4', '\uFEA8', '\uFEAA', '\uFEAC', '\uFEAE', '\uFEB0', '\uFEB4', '\uFEB8', '\uFEBC', '\uFEC0', '\uFEC4', '\uFEC8', '\uFECC', '\uFED0', '\uFED4', '\uFED8', '\uFEDC', '\uFEE0', '\uFEE4', '\uFEE8', '\uFEEC', '\uFEEE', '\uFEF4', '\uFE88', '\uFE84', '\uFE82', '\uFE94', '\uFEF0', '\uFBFF', '\uFE8C', '\uFE86', '\uFE71', '\uFE72', '\uFE74', '\uFE77', '\uFE79', '\uFE7B', '\uFE7D', '\uFE7F', '\uFE80']; |
---|
1084 | |
---|
1085 | /** |
---|
1086 | * Arabic shaped characters in Initial form |
---|
1087 | */ |
---|
1088 | var InitialForm = ['\uFE8D', '\uFE91', '\uFE97', '\uFE9B', '\uFE9F', '\uFEA3', '\uFEA7', '\uFEA9', '\uFEAB', '\uFEAD', '\uFEAF', '\uFEB3', '\uFEB7', '\uFEBB', '\uFEBF', '\uFEC3', '\uFEC7', '\uFECB', '\uFECF', '\uFED3', '\uFED7', '\uFEDB', '\uFEDF', '\uFEE3', '\uFEE7', '\uFEEB', '\uFEED', '\uFEF3', '\uFE87', '\uFE83', '\uFE81', '\uFE93', '\uFEEF', '\uFBFE', '\uFE8B', '\uFE85', '\uFE70', '\uFE72', '\uFE74', '\uFE76', '\uFE78', '\uFE7A', '\uFE7C', '\uFE7E', '\uFE80']; |
---|
1089 | |
---|
1090 | /** |
---|
1091 | * Arabic characters that couldn't join to the next character |
---|
1092 | */ |
---|
1093 | var StandAlonForm = ['\u0621', '\u0627', '\u062F', '\u0630', '\u0631', '\u0632', '\u0648', '\u0622', '\u0629', '\u0626', '\u0624', '\u0625', '\u0675', '\u0623']; |
---|
1094 | |
---|
1095 | var FETo06Table = ['\u064B', '\u064B', '\u064C', '\u061F', '\u064D', '\u061F', '\u064E', '\u064E', '\u064F', '\u064F', '\u0650', '\u0650', '\u0651', '\u0651', '\u0652', '\u0652', '\u0621', '\u0622', '\u0622', '\u0623', '\u0623', '\u0624', '\u0624', '\u0625', '\u0625', '\u0626', '\u0626', '\u0626', '\u0626', '\u0627', '\u0627', '\u0628', '\u0628', '\u0628', '\u0628', '\u0629', '\u0629', '\u062A', '\u062A', '\u062A', '\u062A', '\u062B', '\u062B', '\u062B', '\u062B', '\u062C', '\u062C', '\u062C', '\u062c', '\u062D', '\u062D', '\u062D', '\u062D', '\u062E', '\u062E', '\u062E', '\u062E', '\u062F', '\u062F', '\u0630', '\u0630', '\u0631', '\u0631', '\u0632', '\u0632', '\u0633', '\u0633', '\u0633', '\u0633', '\u0634', '\u0634', '\u0634', '\u0634', '\u0635', '\u0635', '\u0635', '\u0635', '\u0636', '\u0636', '\u0636', '\u0636', '\u0637', '\u0637', '\u0637', '\u0637', '\u0638', '\u0638', '\u0638', '\u0638', '\u0639', '\u0639', '\u0639', '\u0639', '\u063A', '\u063A', '\u063A', '\u063A', '\u0641', '\u0641', '\u0641', '\u0641', '\u0642', '\u0642', '\u0642', '\u0642', '\u0643', '\u0643', '\u0643', '\u0643', '\u0644', '\u0644', '\u0644', '\u0644', '\u0645', '\u0645', '\u0645', '\u0645', '\u0646', '\u0646', '\u0646', '\u0646', '\u0647', '\u0647', '\u0647', '\u0647', '\u0648', '\u0648', '\u0649', '\u0649', '\u064A', '\u064A', '\u064A', '\u064A', '\uFEF5', '\uFEF6', '\uFEF7', '\uFEF8', '\uFEF9', '\uFEFA', '\uFEFB', '\uFEFC', '\u061F', '\u061F', '\u061F']; |
---|
1096 | |
---|
1097 | var ArabicAlefBetIntervalsBegine = ['\u0621', '\u0641']; |
---|
1098 | |
---|
1099 | var ArabicAlefBetIntervalsEnd = ['\u063A', '\u064a']; |
---|
1100 | |
---|
1101 | var Link06 = [ |
---|
1102 | 1 + 32 + 256 * 0x11, |
---|
1103 | 1 + 32 + 256 * 0x13, |
---|
1104 | 1 + 256 * 0x15, |
---|
1105 | 1 + 32 + 256 * 0x17, |
---|
1106 | 1 + 2 + 256 * 0x19, |
---|
1107 | 1 + 32 + 256 * 0x1D, |
---|
1108 | 1 + 2 + 256 * 0x1F, |
---|
1109 | 1 + 256 * 0x23, |
---|
1110 | 1 + 2 + 256 * 0x25, |
---|
1111 | 1 + 2 + 256 * 0x29, |
---|
1112 | 1 + 2 + 256 * 0x2D, |
---|
1113 | 1 + 2 + 256 * 0x31, |
---|
1114 | 1 + 2 + 256 * 0x35, |
---|
1115 | 1 + 256 * 0x39, |
---|
1116 | 1 + 256 * 0x3B, |
---|
1117 | 1 + 256 * 0x3D, |
---|
1118 | 1 + 256 * 0x3F, |
---|
1119 | 1 + 2 + 256 * 0x41, |
---|
1120 | 1 + 2 + 256 * 0x45, |
---|
1121 | 1 + 2 + 256 * 0x49, |
---|
1122 | 1 + 2 + 256 * 0x4D, |
---|
1123 | 1 + 2 + 256 * 0x51, |
---|
1124 | 1 + 2 + 256 * 0x55, |
---|
1125 | 1 + 2 + 256 * 0x59, |
---|
1126 | 1 + 2 + 256 * 0x5D, |
---|
1127 | 0, 0, 0, 0, 0, /* 0x63B - 0x63F */ |
---|
1128 | 1 + 2, |
---|
1129 | 1 + 2 + 256 * 0x61, |
---|
1130 | 1 + 2 + 256 * 0x65, |
---|
1131 | 1 + 2 + 256 * 0x69, |
---|
1132 | 1 + 2 + 16 + 256 * 0x6D, |
---|
1133 | 1 + 2 + 256 * 0x71, |
---|
1134 | 1 + 2 + 256 * 0x75, |
---|
1135 | 1 + 2 + 256 * 0x79, |
---|
1136 | 1 + 256 * 0x7D, |
---|
1137 | 1 + 256 * 0x7F, |
---|
1138 | 1 + 2 + 256 * 0x81, |
---|
1139 | 4, 4, 4, 4, |
---|
1140 | 4, 4, 4, 4, /* 0x64B - 0x652 */ |
---|
1141 | 0, 0, 0, 0, 0, |
---|
1142 | 0, 0, 0, 0, /* 0x653 - 0x65B */ |
---|
1143 | 1 + 256 * 0x85, |
---|
1144 | 1 + 256 * 0x87, |
---|
1145 | 1 + 256 * 0x89, |
---|
1146 | 1 + 256 * 0x8B, |
---|
1147 | 0, 0, 0, 0, 0, |
---|
1148 | 0, 0, 0, 0, 0, |
---|
1149 | 0, 0, 0, 0, 0, 0,/* 0x660 - 0x66F */ |
---|
1150 | 4, |
---|
1151 | 0, |
---|
1152 | 1 + 32, |
---|
1153 | 1 + 32, |
---|
1154 | 0, |
---|
1155 | 1 + 32, |
---|
1156 | 1, 1, |
---|
1157 | 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, |
---|
1158 | 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, |
---|
1159 | 1+2, 1+2, 1+2, 1+2, |
---|
1160 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
---|
1161 | 1, 1, 1, 1, 1, 1, 1, 1, |
---|
1162 | 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, |
---|
1163 | 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, |
---|
1164 | 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, |
---|
1165 | 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, 1+2, |
---|
1166 | 1, |
---|
1167 | 1+2, |
---|
1168 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
---|
1169 | 1+2, |
---|
1170 | 1, |
---|
1171 | 1+2, 1+2, 1+2, 1+2, |
---|
1172 | 1, 1 |
---|
1173 | ]; |
---|
1174 | |
---|
1175 | var LinkFE = [ |
---|
1176 | 1 + 2, |
---|
1177 | 1 + 2, |
---|
1178 | 1 + 2, 0, 1+ 2, 0, 1+ 2, |
---|
1179 | 1 + 2, |
---|
1180 | 1+ 2, 1 + 2, 1+2, 1 + 2, |
---|
1181 | 1+ 2, 1 + 2, 1+2, 1 + 2, |
---|
1182 | 0, 0 + 32, 1 + 32, 0 + 32, |
---|
1183 | 1 + 32, 0, 1, 0 + 32, |
---|
1184 | 1 + 32, 0, 2, 1 + 2, |
---|
1185 | 1, 0 + 32, 1 + 32, 0, |
---|
1186 | 2, 1 + 2, 1, 0, |
---|
1187 | 1, 0, 2, 1 + 2, |
---|
1188 | 1, 0, 2, 1 + 2, |
---|
1189 | 1, 0, 2, 1 + 2, |
---|
1190 | 1, 0, 2, 1 + 2, |
---|
1191 | 1, 0, 2, 1 + 2, |
---|
1192 | 1, 0, 1, 0, |
---|
1193 | 1, 0, 1, 0, |
---|
1194 | 1, 0, 2, 1+2, |
---|
1195 | 1, 0, 2, 1+2, |
---|
1196 | 1, 0, 2, 1+2, |
---|
1197 | 1, 0, 2, 1+2, |
---|
1198 | 1, 0, 2, 1+2, |
---|
1199 | 1, 0, 2, 1+2, |
---|
1200 | 1, 0, 2, 1+2, |
---|
1201 | 1, 0, 2, 1+2, |
---|
1202 | 1, 0, 2, 1+2, |
---|
1203 | 1, 0, 2, 1+2, |
---|
1204 | 1, 0, 2, 1+2, |
---|
1205 | 1, 0 + 16, 2 + 16, 1 + 2 +16, |
---|
1206 | 1 + 16, 0, 2, 1+2, |
---|
1207 | 1, 0, 2, 1+2, |
---|
1208 | 1, 0, 2, 1+2, |
---|
1209 | 1, 0, 1, 0, |
---|
1210 | 1, 0, 2, 1+2, |
---|
1211 | 1, 0, 1, 0, |
---|
1212 | 1, 0, 1, 0, |
---|
1213 | 1 |
---|
1214 | ]; |
---|
1215 | var impTab_LTR = [ |
---|
1216 | /* L, R, EN, AN, N, IL, Cond */ |
---|
1217 | /* 0 LTR text */ [ 0, 3, 0, 1, 0, 0, 0 ], |
---|
1218 | /* 1 LTR+AN */ [ 0, 3, 0, 1, 2, 2, 0 ], |
---|
1219 | /* 2 LTR+AN+N */ [ 0, 3, 0, 0x11, 2, 0, 1 ], |
---|
1220 | /* 3 RTL text */ [ 0, 3, 5, 5, 4, 1, 0 ], |
---|
1221 | /* 4 RTL cont */ [ 0, 3, 0x15, 0x15, 4, 0, 1 ], |
---|
1222 | /* 5 RTL+EN/AN */ [ 0, 3, 5, 5, 4, 2, 0 ] |
---|
1223 | ]; |
---|
1224 | var impTab_RTL = [ |
---|
1225 | /* L, R, EN, AN, N, IL, Cond */ |
---|
1226 | /* 0 RTL text */ [ 2, 0, 1, 1, 0, 1, 0 ], |
---|
1227 | /* 1 RTL+EN/AN */ [ 2, 0, 1, 1, 0, 2, 0 ], |
---|
1228 | /* 2 LTR text */ [ 2, 0, 2, 1, 3, 2, 0 ], |
---|
1229 | /* 3 LTR+cont */ [ 2, 0, 2, 0x21, 3, 1, 1 ] |
---|
1230 | ]; |
---|
1231 | |
---|
1232 | var UBAT_L = 0; /* left to right */ |
---|
1233 | var UBAT_R = 1; /* right to left */ |
---|
1234 | var UBAT_EN = 2; /* European digit */ |
---|
1235 | var UBAT_AN = 3; /* Arabic-Indic digit */ |
---|
1236 | var UBAT_ON = 4; /* neutral */ |
---|
1237 | var UBAT_B = 5; /* block separator */ |
---|
1238 | var UBAT_S = 6; /* segment separator */ |
---|
1239 | var UBAT_AL = 7; /* Arabic Letter */ |
---|
1240 | var UBAT_WS = 8; /* white space */ |
---|
1241 | var UBAT_CS = 9; /* common digit separator */ |
---|
1242 | var UBAT_ES = 10; /* European digit separator */ |
---|
1243 | var UBAT_ET = 11; /* European digit terminator */ |
---|
1244 | var UBAT_NSM = 12; /* Non Spacing Mark */ |
---|
1245 | var UBAT_LRE = 13; /* LRE */ |
---|
1246 | var UBAT_RLE = 14; /* RLE */ |
---|
1247 | var UBAT_PDF = 15; /* PDF */ |
---|
1248 | var UBAT_LRO = 16; /* LRO */ |
---|
1249 | var UBAT_RLO = 17; /* RLO */ |
---|
1250 | var UBAT_BN = 18; /* Boundary Neutral */ |
---|
1251 | |
---|
1252 | var TBBASE = 100; |
---|
1253 | |
---|
1254 | var TB00 = TBBASE + 0; |
---|
1255 | var TB05 = TBBASE + 1; |
---|
1256 | var TB06 = TBBASE + 2; |
---|
1257 | var TB07 = TBBASE + 3; |
---|
1258 | var TB20 = TBBASE + 4; |
---|
1259 | var TBFB = TBBASE + 5; |
---|
1260 | var TBFE = TBBASE + 6; |
---|
1261 | var TBFF = TBBASE + 7; |
---|
1262 | |
---|
1263 | var L = UBAT_L; |
---|
1264 | var R = UBAT_R; |
---|
1265 | var EN = UBAT_EN; |
---|
1266 | var AN = UBAT_AN; |
---|
1267 | var ON = UBAT_ON; |
---|
1268 | var B = UBAT_B; |
---|
1269 | var S = UBAT_S; |
---|
1270 | var AL = UBAT_AL; |
---|
1271 | var WS = UBAT_WS; |
---|
1272 | var CS = UBAT_CS; |
---|
1273 | var ES = UBAT_ES; |
---|
1274 | var ET = UBAT_ET; |
---|
1275 | var NSM = UBAT_NSM; |
---|
1276 | var LRE = UBAT_LRE; |
---|
1277 | var RLE = UBAT_RLE; |
---|
1278 | var PDF = UBAT_PDF; |
---|
1279 | var LRO = UBAT_LRO; |
---|
1280 | var RLO = UBAT_RLO; |
---|
1281 | var BN = UBAT_BN; |
---|
1282 | |
---|
1283 | var MasterTable = [ |
---|
1284 | /************************************************************************************************************************************/ |
---|
1285 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ |
---|
1286 | /************************************************************************************************************************************/ |
---|
1287 | /*0-*/ TB00, L , L , L , L , TB05, TB06, TB07, R , L , L , L , L , L , L , L , |
---|
1288 | /*1-*/ L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , |
---|
1289 | /*2-*/ TB20, ON , ON , ON , L , ON , L , ON , L , ON , ON , ON , L , L , ON , ON , |
---|
1290 | /*3-*/ L , L , L , L , L , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1291 | /*4-*/ ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , L , L , ON , |
---|
1292 | /*5-*/ ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1293 | /*6-*/ ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1294 | /*7-*/ ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1295 | /*8-*/ ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1296 | /*9-*/ ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , L , |
---|
1297 | /*A-*/ L , L , L , L , L , L , L , L , L , L , L , L , L , ON , ON , ON , |
---|
1298 | /*B-*/ ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1299 | /*C-*/ ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1300 | /*D-*/ ON , ON , ON , ON , ON , ON , ON , L , L , ON , ON , L , L , ON , ON , L , |
---|
1301 | /*E-*/ L , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1302 | /*F-*/ ON , ON , ON , ON , ON , ON , ON , ON , L , L , L , TBFB, AL , AL , TBFE, TBFF |
---|
1303 | ]; |
---|
1304 | |
---|
1305 | delete TB00; |
---|
1306 | delete TB05; |
---|
1307 | delete TB06; |
---|
1308 | delete TB07; |
---|
1309 | delete TB20; |
---|
1310 | delete TBFB; |
---|
1311 | delete TBFE; |
---|
1312 | delete TBFF; |
---|
1313 | |
---|
1314 | var UnicodeTable = [ |
---|
1315 | [ /* Table 00: Unicode 00xx */ |
---|
1316 | /************************************************************************************************************************************/ |
---|
1317 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ |
---|
1318 | /************************************************************************************************************************************/ |
---|
1319 | /*0-*/ BN , BN , BN , BN , BN , BN , BN , BN , BN , S , B , S , WS , B , BN , BN , |
---|
1320 | /*1-*/ BN , BN , BN , BN , BN , BN , BN , BN , BN , BN , BN , BN , B , B , B , S , |
---|
1321 | /*2-*/ WS , ON , ON , ET , ET , ET , ON , ON , ON , ON , ON , ES , CS , ES , CS , CS , |
---|
1322 | /*3-*/ EN , EN , EN , EN , EN , EN , EN , EN , EN , EN , CS , ON , ON , ON , ON , ON , |
---|
1323 | /*4-*/ ON , L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , |
---|
1324 | /*5-*/ L , L , L , L , L , L , L , L , L , L , L , ON , ON , ON , ON , ON , |
---|
1325 | /*6-*/ ON , L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , |
---|
1326 | /*7-*/ L , L , L , L , L , L , L , L , L , L , L , ON , ON , ON , ON , BN , |
---|
1327 | /*8-*/ BN , BN , BN , BN , BN , B , BN , BN , BN , BN , BN , BN , BN , BN , BN , BN , |
---|
1328 | /*9-*/ BN , BN , BN , BN , BN , BN , BN , BN , BN , BN , BN , BN , BN , BN , BN , BN , |
---|
1329 | /*A-*/ CS , ON , ET , ET , ET , ET , ON , ON , ON , ON , L , ON , ON , BN , ON , ON , |
---|
1330 | /*B-*/ ET , ET , EN , EN , ON , L , ON , ON , ON , EN , L , ON , ON , ON , ON , ON , |
---|
1331 | /*C-*/ L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , |
---|
1332 | /*D-*/ L , L , L , L , L , L , L , ON , L , L , L , L , L , L , L , L , |
---|
1333 | /*E-*/ L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , |
---|
1334 | /*F-*/ L , L , L , L , L , L , L , ON , L , L , L , L , L , L , L , L |
---|
1335 | ], |
---|
1336 | [ /* Table 01: Unicode 05xx */ |
---|
1337 | /************************************************************************************************************************************/ |
---|
1338 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ |
---|
1339 | /************************************************************************************************************************************/ |
---|
1340 | /*0-*/ L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , |
---|
1341 | /*1-*/ L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , |
---|
1342 | /*2-*/ L , L , L , L , L , L , L , L , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1343 | /*3-*/ ON , L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , |
---|
1344 | /*4-*/ L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , |
---|
1345 | /*5-*/ L , L , L , L , L , L , L , ON , ON , L , L , L , L , L , L , L , |
---|
1346 | /*6-*/ ON , L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , |
---|
1347 | /*7-*/ L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , |
---|
1348 | /*8-*/ L , L , L , L , L , L , L , L , ON , L , ON , ON , ON , ON , ON , ON , |
---|
1349 | /*9-*/ ON , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , |
---|
1350 | /*A-*/ NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , |
---|
1351 | /*B-*/ NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , R , NSM , |
---|
1352 | /*C-*/ R , NSM , NSM , R , NSM , NSM , R , NSM , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1353 | /*D-*/ R , R , R , R , R , R , R , R , R , R , R , R , R , R , R , R , |
---|
1354 | /*E-*/ R , R , R , R , R , R , R , R , R , R , R , ON , ON , ON , ON , ON , |
---|
1355 | /*F-*/ R , R , R , R , R , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON |
---|
1356 | ], |
---|
1357 | [ /* Table 02: Unicode 06xx */ |
---|
1358 | /************************************************************************************************************************************/ |
---|
1359 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ |
---|
1360 | /************************************************************************************************************************************/ |
---|
1361 | /*0-*/ AN , AN , AN , AN , ON , ON , ON , ON , AL , ET , ET , AL , CS , AL , ON , ON , |
---|
1362 | /*1-*/ NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , AL , ON , ON , AL , AL , |
---|
1363 | /*2-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1364 | /*3-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1365 | /*4-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , NSM , NSM , NSM , NSM , NSM , |
---|
1366 | /*5-*/ NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , |
---|
1367 | /*6-*/ AN , AN , AN , AN , AN , AN , AN , AN , AN , AN , ET , AN , AN , AL , AL , AL , |
---|
1368 | /*7-*/ NSM , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1369 | /*8-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1370 | /*9-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1371 | /*A-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1372 | /*B-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1373 | /*C-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1374 | /*D-*/ AL , AL , AL , AL , AL , AL , NSM , NSM , NSM , NSM , NSM , NSM , NSM , AN , ON , NSM , |
---|
1375 | /*E-*/ NSM , NSM , NSM , NSM , NSM , AL , AL , NSM , NSM , ON , NSM , NSM , NSM , NSM , AL , AL , |
---|
1376 | /*F-*/ EN , EN , EN , EN , EN , EN , EN , EN , EN , EN , AL , AL , AL , AL , AL , AL |
---|
1377 | ], |
---|
1378 | [ /* Table 03: Unicode 07xx */ |
---|
1379 | /************************************************************************************************************************************/ |
---|
1380 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ |
---|
1381 | /************************************************************************************************************************************/ |
---|
1382 | /*0-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , ON , AL , |
---|
1383 | /*1-*/ AL , NSM , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1384 | /*2-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1385 | /*3-*/ NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , |
---|
1386 | /*4-*/ NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , ON , ON , AL , AL , AL , |
---|
1387 | /*5-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1388 | /*6-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1389 | /*7-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1390 | /*8-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1391 | /*9-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1392 | /*A-*/ AL , AL , AL , AL , AL , AL , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , |
---|
1393 | /*B-*/ NSM , AL , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1394 | /*C-*/ R , R , R , R , R , R , R , R , R , R , R , R , R , R , R , R , |
---|
1395 | /*D-*/ R , R , R , R , R , R , R , R , R , R , R , R , R , R , R , R , |
---|
1396 | /*E-*/ R , R , R , R , R , R , R , R , R , R , R , NSM , NSM , NSM , NSM , NSM , |
---|
1397 | /*F-*/ NSM , NSM , NSM , NSM , R , R , ON , ON , ON , ON , R , ON , ON , ON , ON , ON |
---|
1398 | ], |
---|
1399 | [ /* Table 04: Unicode 20xx */ |
---|
1400 | /************************************************************************************************************************************/ |
---|
1401 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ |
---|
1402 | /************************************************************************************************************************************/ |
---|
1403 | /*0-*/ WS , WS , WS , WS , WS , WS , WS , WS , WS , WS , WS , BN , BN , BN , L , R , |
---|
1404 | /*1-*/ ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1405 | /*2-*/ ON , ON , ON , ON , ON , ON , ON , ON , WS , B , LRE , RLE , PDF , LRO , RLO , CS , |
---|
1406 | /*3-*/ ET , ET , ET , ET , ET , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1407 | /*4-*/ ON , ON , ON , ON , CS , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1408 | /*5-*/ ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , WS , |
---|
1409 | /*6-*/ BN , BN , BN , BN , BN , ON , ON , ON , ON , ON , BN , BN , BN , BN , BN , BN , |
---|
1410 | /*7-*/ EN , L , ON , ON , EN , EN , EN , EN , EN , EN , ES , ES , ON , ON , ON , L , |
---|
1411 | /*8-*/ EN , EN , EN , EN , EN , EN , EN , EN , EN , EN , ES , ES , ON , ON , ON , ON , |
---|
1412 | /*9-*/ L , L , L , L , L , L , L , L , L , L , L , L , L , ON , ON , ON , |
---|
1413 | /*A-*/ ET , ET , ET , ET , ET , ET , ET , ET , ET , ET , ET , ET , ET , ET , ET , ET , |
---|
1414 | /*B-*/ ET , ET , ET , ET , ET , ET , ET , ET , ET , ET , ON , ON , ON , ON , ON , ON , |
---|
1415 | /*C-*/ ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1416 | /*D-*/ NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , |
---|
1417 | /*E-*/ NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , |
---|
1418 | /*F-*/ NSM , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON |
---|
1419 | ], |
---|
1420 | [ /* Table 05: Unicode FBxx */ |
---|
1421 | /************************************************************************************************************************************/ |
---|
1422 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ |
---|
1423 | /************************************************************************************************************************************/ |
---|
1424 | /*0-*/ L , L , L , L , L , L , L , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1425 | /*1-*/ ON , ON , ON , L , L , L , L , L , ON , ON , ON , ON , ON , R , NSM , R , |
---|
1426 | /*2-*/ R , R , R , R , R , R , R , R , R , ES , R , R , R , R , R , R , |
---|
1427 | /*3-*/ R , R , R , R , R , R , R , ON , R , R , R , R , R , ON , R , ON , |
---|
1428 | /*4-*/ R , R , ON , R , R , ON , R , R , R , R , R , R , R , R , R , R , |
---|
1429 | /*5-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1430 | /*6-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1431 | /*7-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1432 | /*8-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1433 | /*9-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1434 | /*A-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1435 | /*B-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1436 | /*C-*/ AL , AL , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1437 | /*D-*/ ON , ON , ON , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1438 | /*E-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1439 | /*F-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL |
---|
1440 | ], |
---|
1441 | [ /* Table 06: Unicode FExx */ |
---|
1442 | /************************************************************************************************************************************/ |
---|
1443 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ |
---|
1444 | /************************************************************************************************************************************/ |
---|
1445 | /*0-*/ NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , NSM , |
---|
1446 | /*1-*/ ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1447 | /*2-*/ NSM , NSM , NSM , NSM , NSM , NSM , NSM , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1448 | /*3-*/ ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1449 | /*4-*/ ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1450 | /*5-*/ CS , ON , CS , ON , ON , CS , ON , ON , ON , ON , ON , ON , ON , ON , ON , ET , |
---|
1451 | /*6-*/ ON , ON , ES , ES , ON , ON , ON , ON , ON , ET , ET , ON , ON , ON , ON , ON , |
---|
1452 | /*7-*/ AL , AL , AL , AL , AL , ON , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1453 | /*8-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1454 | /*9-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1455 | /*A-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1456 | /*B-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1457 | /*C-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1458 | /*D-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1459 | /*E-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , |
---|
1460 | /*F-*/ AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , AL , ON , ON , BN |
---|
1461 | ], |
---|
1462 | [ /* Table 07: Unicode FFxx */ |
---|
1463 | /************************************************************************************************************************************/ |
---|
1464 | /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ |
---|
1465 | /************************************************************************************************************************************/ |
---|
1466 | /*0-*/ ON , ON , ON , ET , ET , ET , ON , ON , ON , ON , ON , ES , CS , ES , CS , CS , |
---|
1467 | /*1-*/ EN , EN , EN , EN , EN , EN , EN , EN , EN , EN , CS , ON , ON , ON , ON , ON , |
---|
1468 | /*2-*/ ON , L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , |
---|
1469 | /*3-*/ L , L , L , L , L , L , L , L , L , L , L , ON , ON , ON , ON , ON , |
---|
1470 | /*4-*/ ON , L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , |
---|
1471 | /*5-*/ L , L , L , L , L , L , L , L , L , L , L , ON , ON , ON , ON , ON , |
---|
1472 | /*6-*/ ON , ON , ON , ON , ON , ON , L , L , L , L , L , L , L , L , L , L , |
---|
1473 | /*7-*/ L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , |
---|
1474 | /*8-*/ L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , |
---|
1475 | /*9-*/ L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , |
---|
1476 | /*A-*/ L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , |
---|
1477 | /*B-*/ L , L , L , L , L , L , L , L , L , L , L , L , L , L , L , ON , |
---|
1478 | /*C-*/ ON , ON , L , L , L , L , L , L , ON , ON , L , L , L , L , L , L , |
---|
1479 | /*D-*/ ON , ON , L , L , L , L , L , L , ON , ON , L , L , L , ON , ON , ON , |
---|
1480 | /*E-*/ ET , ET , ON , ON , ON , ET , ET , ON , ON , ON , ON , ON , ON , ON , ON , ON , |
---|
1481 | /*F-*/ ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON , ON |
---|
1482 | ] |
---|
1483 | ]; |
---|
1484 | |
---|
1485 | delete L; |
---|
1486 | delete R; |
---|
1487 | delete EN; |
---|
1488 | delete AN; |
---|
1489 | delete ON; |
---|
1490 | delete B; |
---|
1491 | delete S; |
---|
1492 | delete AL; |
---|
1493 | delete WS; |
---|
1494 | delete CS; |
---|
1495 | delete ES; |
---|
1496 | delete ET; |
---|
1497 | delete NSM; |
---|
1498 | delete LRE; |
---|
1499 | delete RLE; |
---|
1500 | delete PDF; |
---|
1501 | delete LRO; |
---|
1502 | delete RLO; |
---|
1503 | delete BN; |
---|
1504 | |
---|
1505 | return dojox.string.BidiEngine; |
---|
1506 | }); |
---|