diff options
Diffstat (limited to 'phpBB/includes/utf/utf_tools.php')
-rw-r--r-- | phpBB/includes/utf/utf_tools.php | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php index 34f9633677..3ee121a179 100644 --- a/phpBB/includes/utf/utf_tools.php +++ b/phpBB/includes/utf/utf_tools.php @@ -1712,11 +1712,12 @@ function utf8_case_fold_nfc($text, $option = 'full') return $text; } -if (!extension_loaded('intl')) +if (extension_loaded('intl')) { /** - * A wrapper function for the normalizer which takes care of including the class if required and modifies the passed strings - * to be in NFC (Normalization Form Composition). + * wrapper around PHP's native normalizer from intl + * previously a PECL extension, included in the core since PHP 5.3.0 + * http://php.net/manual/en/normalizer.normalize.php * * @param mixed $strings a string or an array of strings to normalize * @return mixed the normalized content, preserving array keys if array given. @@ -1728,17 +1729,15 @@ if (!extension_loaded('intl')) return $strings; } - if (!class_exists('utf_normalizer')) - { - global $phpbb_root_path, $phpEx; - include($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx); - } - if (!is_array($strings)) { - utf_normalizer::nfc($strings); + if (Normalizer::isNormalized($strings)) + { + return $strings; + } + return (string) Normalizer::normalize($strings); } - else if (is_array($strings)) + else { foreach ($strings as $key => $string) { @@ -1746,12 +1745,20 @@ if (!extension_loaded('intl')) { foreach ($string as $_key => $_string) { - utf_normalizer::nfc($strings[$key][$_key]); + if (Normalizer::isNormalized($strings[$key][$_key])) + { + continue; + } + $strings[$key][$_key] = (string) Normalizer::normalize($strings[$key][$_key]); } } else { - utf_normalizer::nfc($strings[$key]); + if (Normalizer::isNormalized($strings[$key])) + { + continue; + } + $strings[$key] = (string) Normalizer::normalize($strings[$key]); } } } @@ -1761,10 +1768,9 @@ if (!extension_loaded('intl')) } else { - /** - * wrapper around PHP's native normalizer from intl - * previously a PECL extension, included in the core since PHP 5.3.0 - * http://php.net/manual/en/normalizer.normalize.php + /** + * A wrapper function for the normalizer which takes care of including the class if + * required and modifies the passed strings to be in NFC (Normalization Form Composition). * * @param mixed $strings a string or an array of strings to normalize * @return mixed the normalized content, preserving array keys if array given. @@ -1776,15 +1782,17 @@ else return $strings; } + if (!class_exists('utf_normalizer')) + { + global $phpbb_root_path, $phpEx; + include($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx); + } + if (!is_array($strings)) { - if (Normalizer::isNormalized($strings)) - { - return $strings; - } - return (string) Normalizer::normalize($strings); + utf_normalizer::nfc($strings); } - else + else if (is_array($strings)) { foreach ($strings as $key => $string) { @@ -1792,20 +1800,12 @@ else { foreach ($string as $_key => $_string) { - if (Normalizer::isNormalized($strings[$key][$_key])) - { - continue; - } - $strings[$key][$_key] = (string) Normalizer::normalize($strings[$key][$_key]); + utf_normalizer::nfc($strings[$key][$_key]); } } else { - if (Normalizer::isNormalized($strings[$key])) - { - continue; - } - $strings[$key] = (string) Normalizer::normalize($strings[$key]); + utf_normalizer::nfc($strings[$key]); } } } |