| @@ 2570-2588 (lines=19) @@ | ||
| 2567 | // Workaround https://bugs.php.net/65732 |
|
| 2568 | $var = str_replace(array("\r\n", "\r"), "\n", $var); |
|
| 2569 | } |
|
| 2570 | if (preg_match('/[\x80-\xFF]/', $var)) { |
|
| 2571 | if (Normalizer::isNormalized($var, $normalization_form)) { |
|
| 2572 | $n = '-'; |
|
| 2573 | } else { |
|
| 2574 | $n = Normalizer::normalize($var, $normalization_form); |
|
| 2575 | ||
| 2576 | if (isset($n[0])) { |
|
| 2577 | $var = $n; |
|
| 2578 | } else { |
|
| 2579 | $var = self::encode('UTF-8', $var); |
|
| 2580 | } |
|
| 2581 | ||
| 2582 | } |
|
| 2583 | if ($var[0] >= "\x80" && isset($n[0], $leading_combining[0]) && preg_match('/^\p{Mn}/u', $var)) { |
|
| 2584 | // Prevent leading combining chars |
|
| 2585 | // for NFC-safe concatenations. |
|
| 2586 | $var = $leading_combining . $var; |
|
| 2587 | } |
|
| 2588 | } |
|
| 2589 | break; |
|
| 2590 | } |
|
| 2591 | ||
| @@ 545-562 (lines=18) @@ | ||
| 542 | $s = str_replace(array("\r\n", "\r"), "\n", $s); |
|
| 543 | } |
|
| 544 | ||
| 545 | if (preg_match('/[\x80-\xFF]/', $s)) { |
|
| 546 | if (Normalizer::isNormalized($s, $normalization_form)) { |
|
| 547 | $n = '-'; |
|
| 548 | } else { |
|
| 549 | $n = Normalizer::normalize($s, $normalization_form); |
|
| 550 | if (isset($n[0])) { |
|
| 551 | $s = $n; |
|
| 552 | } else { |
|
| 553 | $s = UTF8::encode('UTF-8', $s); |
|
| 554 | } |
|
| 555 | } |
|
| 556 | ||
| 557 | if ($s[0] >= "\x80" && isset($n[0], $leading_combining[0]) && preg_match('/^\p{Mn}/u', $s)) { |
|
| 558 | // Prevent leading combining chars |
|
| 559 | // for NFC-safe concatenations. |
|
| 560 | $s = $leading_combining . $s; |
|
| 561 | } |
|
| 562 | } |
|
| 563 | ||
| 564 | return $s; |
|
| 565 | } |
|