| 1 |
<?php |
| 2 |
|
| 3 |
class MYANMAR |
| 4 |
{ |
| 5 |
/* FROM hb-ot-shape-complex-indic-private.hh */ |
| 6 |
|
| 7 |
// indic_category |
| 8 |
const OT_X = 0; |
| 9 |
const OT_C = 1; |
| 10 |
const OT_V = 2; |
| 11 |
const OT_N = 3; |
| 12 |
const OT_H = 4; |
| 13 |
const OT_ZWNJ = 5; |
| 14 |
const OT_ZWJ = 6; |
| 15 |
const OT_M = 7; /* Matra or Dependent Vowel */ |
| 16 |
const OT_SM = 8; |
| 17 |
const OT_VD = 9; |
| 18 |
const OT_A = 10; |
| 19 |
const OT_NBSP = 11; |
| 20 |
const OT_DOTTEDCIRCLE = 12; /* Not in the spec, but special in Uniscribe. /Very very/ special! */ |
| 21 |
const OT_RS = 13; /* Register Shifter, used in Khmer OT spec */ |
| 22 |
const OT_Coeng = 14; |
| 23 |
const OT_Repha = 15; |
| 24 |
const OT_Ra = 16; /* Not explicitly listed in the OT spec, but used in the grammar. */ |
| 25 |
const OT_CM = 17; |
| 26 |
|
| 27 |
/* FROM hb-ot-shape-complex-myanmar.hh */ |
| 28 |
|
| 29 |
// myanmar_category |
| 30 |
const OT_DB = 3; // same as INDIC::OT_N; /* Dot below */ |
| 31 |
const OT_GB = 12; // same as INDIC::OT_DOTTEDCIRCLE; |
| 32 |
const OT_As = 18; /* Asat */ |
| 33 |
const OT_D = 19; /* Digits except zero */ |
| 34 |
const OT_D0 = 20; /* Digit zero */ |
| 35 |
const OT_MH = 21; /* Various consonant medial types */ |
| 36 |
const OT_MR = 22; /* Various consonant medial types */ |
| 37 |
const OT_MW = 23; /* Various consonant medial types */ |
| 38 |
const OT_MY = 24; /* Various consonant medial types */ |
| 39 |
const OT_PT = 25; /* Pwo and other tones */ |
| 40 |
|
| 41 |
const OT_VAbv = 26; |
| 42 |
const OT_VBlw = 27; |
| 43 |
const OT_VPre = 28; |
| 44 |
const OT_VPst = 29; |
| 45 |
const OT_VS = 30; /* Variation selectors */ |
| 46 |
|
| 47 |
// Based on myanmar_category used to make string to find syllables |
| 48 |
// OT_ to string character (using e.g. OT_C from MYANMAR) hb-ot-shape-complex-myanmar-private.hh |
| 49 |
public static $myanmar_category_char = array( |
| 50 |
'x', |
| 51 |
'C', |
| 52 |
'V', |
| 53 |
'N', |
| 54 |
'H', |
| 55 |
'Z', |
| 56 |
'J', |
| 57 |
'x', |
| 58 |
'S', |
| 59 |
'x', |
| 60 |
'A', |
| 61 |
'x', |
| 62 |
'D', |
| 63 |
'x', |
| 64 |
'x', |
| 65 |
'x', |
| 66 |
'R', |
| 67 |
'x', |
| 68 |
'a', /* As Asat */ |
| 69 |
'd', /* Digits except zero */ |
| 70 |
'o', /* Digit zero */ |
| 71 |
'k', /* Medial types */ |
| 72 |
'l', /* Medial types */ |
| 73 |
'm', /* Medial types */ |
| 74 |
'n', /* Medial types */ |
| 75 |
'p', /* Pwo and other tones */ |
| 76 |
'v', /* Vowel aboVe */ |
| 77 |
'b', /* Vowel Below */ |
| 78 |
'e', /* Vowel prE */ |
| 79 |
't', /* Vowel posT */ |
| 80 |
's', /* variation Selector */ |
| 81 |
); |
| 82 |
|
| 83 |
/* Visual positions in a syllable from left to right. */ |
| 84 |
/* FROM hb-ot-shape-complex-myanmar-private.hh */ |
| 85 |
|
| 86 |
// myanmar_position |
| 87 |
const POS_START = 0; |
| 88 |
|
| 89 |
const POS_RA_TO_BECOME_REPH = 1; |
| 90 |
const POS_PRE_M = 2; |
| 91 |
const POS_PRE_C = 3; |
| 92 |
|
| 93 |
const POS_BASE_C = 4; |
| 94 |
const POS_AFTER_MAIN = 5; |
| 95 |
|
| 96 |
const POS_ABOVE_C = 6; |
| 97 |
|
| 98 |
const POS_BEFORE_SUB = 7; |
| 99 |
const POS_BELOW_C = 8; |
| 100 |
const POS_AFTER_SUB = 9; |
| 101 |
|
| 102 |
const POS_BEFORE_POST = 10; |
| 103 |
const POS_POST_C = 11; |
| 104 |
const POS_AFTER_POST = 12; |
| 105 |
|
| 106 |
const POS_FINAL_C = 13; |
| 107 |
const POS_SMVD = 14; |
| 108 |
|
| 109 |
const POS_END = 15; |
| 110 |
|
| 111 |
public static function set_myanmar_properties(&$info) |
| 112 |
{ |
| 113 |
$u = $info['uni']; |
| 114 |
$type = self::myanmar_get_categories($u); |
| 115 |
$cat = ($type & 0x7F); |
| 116 |
$pos = ($type >> 8); |
| 117 |
/* |
| 118 |
* Re-assign category |
| 119 |
* http://www.microsoft.com/typography/OpenTypeDev/myanmar/intro.htm#analyze |
| 120 |
*/ |
| 121 |
if (self::in_range($u, 0xFE00, 0xFE0F)) |
| 122 |
$cat = self::OT_VS; |
| 123 |
else if ($u == 0x200C) |
| 124 |
$cat = self::OT_ZWNJ; |
| 125 |
else if ($u == 0x200D) |
| 126 |
$cat = self::OT_ZWJ; |
| 127 |
|
| 128 |
switch ($u) { |
| 129 |
case 0x002D: case 0x00A0: case 0x00D7: case 0x2012: |
| 130 |
case 0x2013: case 0x2014: case 0x2015: case 0x2022: |
| 131 |
case 0x25CC: case 0x25FB: case 0x25FC: case 0x25FD: |
| 132 |
case 0x25FE: |
| 133 |
$cat = self::OT_GB; |
| 134 |
break; |
| 135 |
|
| 136 |
case 0x1004: case 0x101B: case 0x105A: |
| 137 |
$cat = self::OT_Ra; |
| 138 |
break; |
| 139 |
|
| 140 |
case 0x1032: case 0x1036: |
| 141 |
$cat = self::OT_A; |
| 142 |
break; |
| 143 |
|
| 144 |
case 0x103A: |
| 145 |
$cat = self::OT_As; |
| 146 |
break; |
| 147 |
|
| 148 |
case 0x1041: case 0x1042: case 0x1043: case 0x1044: |
| 149 |
case 0x1045: case 0x1046: case 0x1047: case 0x1048: |
| 150 |
case 0x1049: case 0x1090: case 0x1091: case 0x1092: |
| 151 |
case 0x1093: case 0x1094: case 0x1095: case 0x1096: |
| 152 |
case 0x1097: case 0x1098: case 0x1099: |
| 153 |
$cat = self::OT_D; |
| 154 |
break; |
| 155 |
|
| 156 |
case 0x1040: |
| 157 |
$cat = self::OT_D; /* XXX The spec says D0, but Uniscribe doesn't seem to do. */ |
| 158 |
break; |
| 159 |
|
| 160 |
case 0x103E: case 0x1060: |
| 161 |
$cat = self::OT_MH; |
| 162 |
break; |
| 163 |
|
| 164 |
case 0x103C: |
| 165 |
$cat = self::OT_MR; |
| 166 |
break; |
| 167 |
|
| 168 |
case 0x103D: case 0x1082: |
| 169 |
$cat = self::OT_MW; |
| 170 |
break; |
| 171 |
|
| 172 |
case 0x103B: case 0x105E: case 0x105F: |
| 173 |
$cat = self::OT_MY; |
| 174 |
break; |
| 175 |
|
| 176 |
case 0x1063: case 0x1064: case 0x1069: case 0x106A: |
| 177 |
case 0x106B: case 0x106C: case 0x106D: case 0xAA7B: |
| 178 |
$cat = self::OT_PT; |
| 179 |
break; |
| 180 |
|
| 181 |
case 0x1038: case 0x1087: case 0x1088: case 0x1089: |
| 182 |
case 0x108A: case 0x108B: case 0x108C: case 0x108D: |
| 183 |
case 0x108F: case 0x109A: case 0x109B: case 0x109C: |
| 184 |
$cat = self::OT_SM; |
| 185 |
break; |
| 186 |
} |
| 187 |
|
| 188 |
if ($cat == self::OT_M) { |
| 189 |
switch ($pos) { |
| 190 |
case self::POS_PRE_C: |
| 191 |
$cat = self::OT_VPre; |
| 192 |
$pos = self::POS_PRE_M; |
| 193 |
break; |
| 194 |
case self::POS_ABOVE_C: $cat = self::OT_VAbv; |
| 195 |
break; |
| 196 |
case self::POS_BELOW_C: $cat = self::OT_VBlw; |
| 197 |
break; |
| 198 |
case self::POS_POST_C: $cat = self::OT_VPst; |
| 199 |
break; |
| 200 |
} |
| 201 |
} |
| 202 |
$info['myanmar_category'] = $cat; |
| 203 |
$info['myanmar_position'] = $pos; |
| 204 |
} |
| 205 |
|
| 206 |
// syllable_type |
| 207 |
const CONSONANT_SYLLABLE = 0; |
| 208 |
const BROKEN_CLUSTER = 3; |
| 209 |
const NON_MYANMAR_CLUSTER = 4; |
| 210 |
|
| 211 |
public static function set_syllables(&$o, $s, &$broken_syllables) |
| 212 |
{ |
| 213 |
$ptr = 0; |
| 214 |
$syllable_serial = 1; |
| 215 |
$broken_syllables = false; |
| 216 |
|
| 217 |
while ($ptr < strlen($s)) { |
| 218 |
$match = ''; |
| 219 |
$syllable_length = 1; |
| 220 |
$syllable_type = self::NON_MYANMAR_CLUSTER; |
| 221 |
// CONSONANT_SYLLABLE Consonant syllable |
| 222 |
// From OT spec: |
| 223 |
if (preg_match('/^(RaH)?([C|R]|V|d|D)[s]?(H([C|R|V])[s]?)*(H|[a]*[n]?[l]?((m[k]?|k)[a]?)?[e]*[v]*[b]*[A]*(N[a]?)?(t[k]?[a]*[v]*[A]*(N[a]?)?)*(p[A]*(N[a]?)?)*S*[J|Z]?)/', substr($s, $ptr), $ma)) { |
| 224 |
$syllable_length = strlen($ma[0]); |
| 225 |
$syllable_type = self::CONSONANT_SYLLABLE; |
| 226 |
} |
| 227 |
|
| 228 |
// BROKEN_CLUSTER syllable |
| 229 |
else if (preg_match('/^(RaH)?s?(H|[a]*[n]?[l]?((m[k]?|k)[a]?)?[e]*[v]*[b]*[A]*(N[a]?)?(t[k]?[a]*[v]*[A]*(N[a]?)?)*(p[A]*(N[a]?)?)*S*[J|Z]?)/', substr($s, $ptr), $ma)) { |
| 230 |
if (strlen($ma[0])) { // May match blank |
| 231 |
$syllable_length = strlen($ma[0]); |
| 232 |
$syllable_type = self::BROKEN_CLUSTER; |
| 233 |
$broken_syllables = true; |
| 234 |
} |
| 235 |
} |
| 236 |
for ($i = $ptr; $i < $ptr + $syllable_length; $i++) { |
| 237 |
$o[$i]['syllable'] = ($syllable_serial << 4) | $syllable_type; |
| 238 |
} |
| 239 |
$ptr += $syllable_length; |
| 240 |
$syllable_serial++; |
| 241 |
if ($syllable_serial == 16) |
| 242 |
$syllable_serial = 1; |
| 243 |
} |
| 244 |
} |
| 245 |
|
| 246 |
public static function reordering(&$info, $GSUBdata, $broken_syllables, $dottedcircle) |
| 247 |
{ |
| 248 |
if ($broken_syllables && $dottedcircle) { |
| 249 |
self::insert_dotted_circles($info, $dottedcircle); |
| 250 |
} |
| 251 |
$count = count($info); |
| 252 |
if (!$count) |
| 253 |
return; |
| 254 |
$last = 0; |
| 255 |
$last_syllable = $info[0]['syllable']; |
| 256 |
for ($i = 1; $i < $count; $i++) { |
| 257 |
if ($last_syllable != $info[$i]['syllable']) { |
| 258 |
self::reordering_syllable($info, $GSUBdata, $last, $i); |
| 259 |
$last = $i; |
| 260 |
$last_syllable = $info[$last]['syllable']; |
| 261 |
} |
| 262 |
} |
| 263 |
self::reordering_syllable($info, $GSUBdata, $last, $count); |
| 264 |
} |
| 265 |
|
| 266 |
public static function insert_dotted_circles(&$info, $dottedcircle) |
| 267 |
{ |
| 268 |
$idx = 0; |
| 269 |
$last_syllable = 0; |
| 270 |
while ($idx < count($info)) { |
| 271 |
$syllable = $info[$idx]['syllable']; |
| 272 |
$syllable_type = ($syllable & 0x0F); |
| 273 |
if ($last_syllable != $syllable && $syllable_type == self::BROKEN_CLUSTER) { |
| 274 |
$last_syllable = $syllable; |
| 275 |
$dottedcircle[0]['syllable'] = $info[$idx]['syllable']; |
| 276 |
array_splice($info, $idx, 0, $dottedcircle); |
| 277 |
} else |
| 278 |
$idx++; |
| 279 |
} |
| 280 |
// In case of final bloken cluster... |
| 281 |
$syllable = $info[$idx]['syllable']; |
| 282 |
$syllable_type = ($syllable & 0x0F); |
| 283 |
if ($last_syllable != $syllable && $syllable_type == self::BROKEN_CLUSTER) { |
| 284 |
$dottedcircle[0]['syllable'] = $info[$idx]['syllable']; |
| 285 |
array_splice($info, $idx, 0, $dottedcircle); |
| 286 |
} |
| 287 |
} |
| 288 |
|
| 289 |
/* Rules from: |
| 290 |
* https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx */ |
| 291 |
|
| 292 |
public static function reordering_syllable(&$info, $GSUBdata, $start, $end) |
| 293 |
{ |
| 294 |
/* vowel_syllable: We made the vowels look like consonants. So uses the consonant logic! */ |
| 295 |
/* broken_cluster: We already inserted dotted-circles, so just call the standalone_cluster. */ |
| 296 |
|
| 297 |
$syllable_type = ($info[$start]['syllable'] & 0x0F); |
| 298 |
if ($syllable_type == self::NON_MYANMAR_CLUSTER) { |
| 299 |
return; |
| 300 |
} |
| 301 |
if ($syllable_type == self::BROKEN_CLUSTER) { |
| 302 |
//if ($uniscribe_bug_compatible) { |
| 303 |
/* For dotted-circle, this is what Uniscribe does: |
| 304 |
* If dotted-circle is the last glyph, it just does nothing. |
| 305 |
* i.e. It doesn't form Reph. */ |
| 306 |
if ($info[$end - 1]['myanmar_category'] == self::OT_DOTTEDCIRCLE) { |
| 307 |
return; |
| 308 |
} |
| 309 |
} |
| 310 |
|
| 311 |
$base = $end; |
| 312 |
$has_reph = false; |
| 313 |
$limit = $start; |
| 314 |
|
| 315 |
if (($start + 3 <= $end) && |
| 316 |
$info[$start]['myanmar_category'] == self::OT_Ra && |
| 317 |
$info[$start + 1]['myanmar_category'] == self::OT_As && |
| 318 |
$info[$start + 2]['myanmar_category'] == self::OT_H) { |
| 319 |
$limit += 3; |
| 320 |
$base = $start; |
| 321 |
$has_reph = true; |
| 322 |
} |
| 323 |
|
| 324 |
if (!$has_reph) |
| 325 |
$base = $limit; |
| 326 |
|
| 327 |
for ($i = $limit; $i < $end; $i++) { |
| 328 |
if (self::is_consonant($info[$i])) { |
| 329 |
$base = $i; |
| 330 |
break; |
| 331 |
} |
| 332 |
} |
| 333 |
|
| 334 |
|
| 335 |
/* Reorder! */ |
| 336 |
$i = $start; |
| 337 |
for (; $i < $start + ($has_reph ? 3 : 0); $i++) |
| 338 |
$info[$i]['myanmar_position'] = self::POS_AFTER_MAIN; |
| 339 |
for (; $i < $base; $i++) |
| 340 |
$info[$i]['myanmar_position'] = self::POS_PRE_C; |
| 341 |
if ($i < $end) { |
| 342 |
$info[$i]['myanmar_position'] = self::POS_BASE_C; |
| 343 |
$i++; |
| 344 |
} |
| 345 |
$pos = self::POS_AFTER_MAIN; |
| 346 |
/* The following loop may be ugly, but it implements all of |
| 347 |
* Myanmar reordering! */ |
| 348 |
for (; $i < $end; $i++) { |
| 349 |
if ($info[$i]['myanmar_category'] == self::OT_MR) /* Pre-base reordering */ { |
| 350 |
$info[$i]['myanmar_position'] = self::POS_PRE_C; |
| 351 |
continue; |
| 352 |
} |
| 353 |
if ($info[$i]['myanmar_position'] < self::POS_BASE_C) /* Left matra */ { |
| 354 |
continue; |
| 355 |
} |
| 356 |
|
| 357 |
if ($pos == self::POS_AFTER_MAIN && $info[$i]['myanmar_category'] == self::OT_VBlw) { |
| 358 |
$pos = self::POS_BELOW_C; |
| 359 |
$info[$i]['myanmar_position'] = $pos; |
| 360 |
continue; |
| 361 |
} |
| 362 |
|
| 363 |
if ($pos == self::POS_BELOW_C && $info[$i]['myanmar_category'] == self::OT_A) { |
| 364 |
$info[$i]['myanmar_position'] = self::POS_BEFORE_SUB; |
| 365 |
continue; |
| 366 |
} |
| 367 |
if ($pos == self::POS_BELOW_C && $info[$i]['myanmar_category'] == self::OT_VBlw) { |
| 368 |
$info[$i]['myanmar_position'] = $pos; |
| 369 |
continue; |
| 370 |
} |
| 371 |
if ($pos == self::POS_BELOW_C && $info[$i]['myanmar_category'] != self::OT_A) { |
| 372 |
$pos = self::POS_AFTER_SUB; |
| 373 |
$info[$i]['myanmar_position'] = $pos; |
| 374 |
continue; |
| 375 |
} |
| 376 |
$info[$i]['myanmar_position'] = $pos; |
| 377 |
} |
| 378 |
|
| 379 |
|
| 380 |
/* Sit tight, rock 'n roll! */ |
| 381 |
self::bubble_sort($info, $start, $end - $start); |
| 382 |
} |
| 383 |
|
| 384 |
public static function is_one_of($info, $flags) |
| 385 |
{ |
| 386 |
if (isset($info['is_ligature']) && $info['is_ligature']) |
| 387 |
return false; /* If it ligated, all bets are off. */ |
| 388 |
return !!(self::FLAG($info['myanmar_category']) & $flags); |
| 389 |
} |
| 390 |
|
| 391 |
/* Vowels and placeholders treated as if they were consonants. */ |
| 392 |
|
| 393 |
public static function is_consonant($info) |
| 394 |
{ |
| 395 |
return self::is_one_of($info, (self::FLAG(self::OT_C) | self::FLAG(self::OT_CM) | self::FLAG(self::OT_Ra) | self::FLAG(self::OT_V) | self::FLAG(self::OT_NBSP) | self::FLAG(self::OT_GB))); |
| 396 |
} |
| 397 |
|
| 398 |
// From hb-private.hh |
| 399 |
public static function in_range($u, $lo, $hi) |
| 400 |
{ |
| 401 |
if ((($lo ^ $hi) & $lo) == 0 && (($lo ^ $hi) & $hi) == ($lo ^ $hi) && (($lo ^ $hi) & (($lo ^ $hi) + 1)) == 0) |
| 402 |
return ($u & ~($lo ^ $hi)) == $lo; |
| 403 |
else |
| 404 |
return $lo <= $u && $u <= $hi; |
| 405 |
} |
| 406 |
|
| 407 |
// From hb-private.hh |
| 408 |
public static function FLAG($x) |
| 409 |
{ |
| 410 |
return (1 << ($x)); |
| 411 |
} |
| 412 |
|
| 413 |
public static function FLAG_RANGE($x, $y) |
| 414 |
{ |
| 415 |
self::FLAG(y + 1) - self::FLAG(x); |
| 416 |
} |
| 417 |
|
| 418 |
// BELOW from hb-ot-shape-complex-indic.cc |
| 419 |
// see INDIC for details |
| 420 |
|
| 421 |
public static $myanmar_table = array( |
| 422 |
/* Myanmar (1000..109F) */ |
| 423 |
|
| 424 |
/* 1000 */ 3841, 3841, 3841, 3841, 3841, 3841, 3841, 3841, |
| 425 |
/* 1008 */ 3841, 3841, 3841, 3841, 3841, 3841, 3841, 3841, |
| 426 |
/* 1010 */ 3841, 3841, 3841, 3841, 3841, 3841, 3841, 3841, |
| 427 |
/* 1018 */ 3841, 3841, 3841, 3841, 3841, 3841, 3841, 3841, |
| 428 |
/* 1020 */ 3841, 3842, 3842, 3842, 3842, 3842, 3842, 3842, |
| 429 |
/* 1028 */ 3842, 3842, 3842, 2823, 2823, 1543, 1543, 2055, |
| 430 |
/* 1030 */ 2055, 775, 1543, 1543, 1543, 1543, 3848, 3843, |
| 431 |
/* 1038 */ 3848, 3844, 1540, 3857, 3857, 3857, 3857, 3841, |
| 432 |
/* 1040 */ 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, |
| 433 |
/* 1048 */ 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, |
| 434 |
/* 1050 */ 3841, 3841, 3842, 3842, 3842, 3842, 2823, 2823, |
| 435 |
/* 1058 */ 2055, 2055, 3841, 3841, 3841, 3841, 3857, 3857, |
| 436 |
/* 1060 */ 3857, 3841, 2823, 3843, 3843, 3841, 3841, 2823, |
| 437 |
/* 1068 */ 2823, 3843, 3843, 3843, 3843, 3843, 3841, 3841, |
| 438 |
/* 1070 */ 3841, 1543, 1543, 1543, 1543, 3841, 3841, 3841, |
| 439 |
/* 1078 */ 3841, 3841, 3841, 3841, 3841, 3841, 3841, 3841, |
| 440 |
/* 1080 */ 3841, 3841, 3857, 2823, 775, 1543, 1543, 3843, |
| 441 |
/* 1088 */ 3843, 3843, 3843, 3843, 3843, 3843, 3841, 3843, |
| 442 |
/* 1090 */ 3840, 3840, 3840, 3840, 3840, 3840, 3840, 3840, |
| 443 |
/* 1098 */ 3840, 3840, 3843, 3843, 2823, 1543, 3840, 3840, |
| 444 |
/* Myanmar Extended-A (AA60..AA7F) */ |
| 445 |
|
| 446 |
/* AA60 */ 3841, 3841, 3841, 3841, 3841, 3841, 3841, 3841, |
| 447 |
/* AA68 */ 3841, 3841, 3841, 3841, 3841, 3841, 3841, 3841, |
| 448 |
/* AA70 */ 3840, 3841, 3841, 3841, 3840, 3840, 3840, 3840, |
| 449 |
/* AA78 */ 3840, 3840, 3841, 3843, 3840, 3840, 3840, 3840, |
| 450 |
); |
| 451 |
|
| 452 |
// from "hb-ot-shape-complex-indic-table.cc" |
| 453 |
public static function myanmar_get_categories($u) |
| 454 |
{ |
| 455 |
if (0x1000 <= $u && $u <= 0x109F) |
| 456 |
return self::$myanmar_table[$u - 0x1000 + 0]; // offset 0 for Most "myanmar" |
| 457 |
if (0xAA60 <= $u && $u <= 0xAA7F) |
| 458 |
return self::$myanmar_table[$u - 0xAA60 + 160]; // offset for extensions |
| 459 |
if ($u == 0x00A0) |
| 460 |
return 3851; // (ISC_CP | (IMC_x << 8)) |
| 461 |
if ($u == 0x25CC) |
| 462 |
return 3851; // (ISC_CP | (IMC_x << 8)) |
| 463 |
return 3840; // (ISC_x | (IMC_x << 8)) |
| 464 |
} |
| 465 |
|
| 466 |
public static function bubble_sort(&$arr, $start, $len) |
| 467 |
{ |
| 468 |
if ($len < 2) { |
| 469 |
return; |
| 470 |
} |
| 471 |
$k = $start + $len - 2; |
| 472 |
while ($k >= $start) { |
| 473 |
for ($j = $start; $j <= $k; $j++) { |
| 474 |
if ($arr[$j]['myanmar_position'] > $arr[$j + 1]['myanmar_position']) { |
| 475 |
$t = $arr[$j]; |
| 476 |
$arr[$j] = $arr[$j + 1]; |
| 477 |
$arr[$j + 1] = $t; |
| 478 |
} |
| 479 |
} |
| 480 |
$k--; |
| 481 |
} |
| 482 |
} |
| 483 |
|
| 484 |
} |
| 485 |
|