| @@ 185-202 (lines=18) @@ | ||
| 182 | $s = str_replace(array("\r\n", "\r"), "\n", $s); |
|
| 183 | } |
|
| 184 | ||
| 185 | if (preg_match('/[\x80-\xFF]/', $s)) { |
|
| 186 | if (Normalizer::isNormalized($s, $normalization_form)) { |
|
| 187 | $n = '-'; |
|
| 188 | } else { |
|
| 189 | $n = Normalizer::normalize($s, $normalization_form); |
|
| 190 | if (isset($n[0])) { |
|
| 191 | $s = $n; |
|
| 192 | } else { |
|
| 193 | $s = UTF8::encode('UTF-8', $s); |
|
| 194 | } |
|
| 195 | } |
|
| 196 | ||
| 197 | if ($s[0] >= "\x80" && isset($n[0], $leading_combining[0]) && preg_match('/^\p{Mn}/u', $s)) { |
|
| 198 | // Prevent leading combining chars |
|
| 199 | // for NFC-safe concatenations. |
|
| 200 | $s = $leading_combining . $s; |
|
| 201 | } |
|
| 202 | } |
|
| 203 | ||
| 204 | return $s; |
|
| 205 | } |
|
| @@ 1889-1907 (lines=19) @@ | ||
| 1886 | // Workaround https://bugs.php.net/65732 |
|
| 1887 | $var = str_replace(array("\r\n", "\r"), "\n", $var); |
|
| 1888 | } |
|
| 1889 | if (preg_match('/[\x80-\xFF]/', $var)) { |
|
| 1890 | if (Normalizer::isNormalized($var, $normalization_form)) { |
|
| 1891 | $n = '-'; |
|
| 1892 | } else { |
|
| 1893 | $n = Normalizer::normalize($var, $normalization_form); |
|
| 1894 | ||
| 1895 | if (isset($n[0])) { |
|
| 1896 | $var = $n; |
|
| 1897 | } else { |
|
| 1898 | $var = self::encode('UTF-8', $var); |
|
| 1899 | } |
|
| 1900 | ||
| 1901 | } |
|
| 1902 | if ($var[0] >= "\x80" && isset($n[0], $leading_combining[0]) && preg_match('/^\p{Mn}/u', $var)) { |
|
| 1903 | // Prevent leading combining chars |
|
| 1904 | // for NFC-safe concatenations. |
|
| 1905 | $var = $leading_combining . $var; |
|
| 1906 | } |
|
| 1907 | } |
|
| 1908 | break; |
|
| 1909 | } |
|
| 1910 | ||