aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/utf/utf_tools.php
diff options
context:
space:
mode:
authorDavid M <davidmj@users.sourceforge.net>2007-07-15 21:20:03 +0000
committerDavid M <davidmj@users.sourceforge.net>2007-07-15 21:20:03 +0000
commitf613f721531aed835a641b5456afa1808949f02b (patch)
tree64691b18338e887ca6d864fea6c999cef838c007 /phpBB/includes/utf/utf_tools.php
parent909e195a9b54f38294f217ee8e10b17a62876756 (diff)
downloadforums-f613f721531aed835a641b5456afa1808949f02b.tar
forums-f613f721531aed835a641b5456afa1808949f02b.tar.gz
forums-f613f721531aed835a641b5456afa1808949f02b.tar.bz2
forums-f613f721531aed835a641b5456afa1808949f02b.tar.xz
forums-f613f721531aed835a641b5456afa1808949f02b.zip
remove code duplication
git-svn-id: file:///svn/phpbb/trunk@7891 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/utf/utf_tools.php')
-rw-r--r--phpBB/includes/utf/utf_tools.php65
1 files changed, 10 insertions, 55 deletions
diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php
index cb13d370a4..0c6b5d0006 100644
--- a/phpBB/includes/utf/utf_tools.php
+++ b/phpBB/includes/utf/utf_tools.php
@@ -1057,15 +1057,20 @@ function utf8_case_fold($text, $option = 'full')
$uniarray['s'] = include($phpbb_root_path . 'includes/utf/data/case_fold_s.' . $phpEx);
}
+ // common is always replaced
$text = strtr($text, $uniarray['c']);
+
if ($option === 'full')
{
+ // full replaces a character with multiple characters
$text = strtr($text, $uniarray['f']);
}
else
{
+ // simple replaces a character with another character
$text = strtr($text, $uniarray['s']);
}
+
return $text;
}
@@ -1079,7 +1084,6 @@ function utf8_case_fold($text, $option = 'full')
*/
function utf8_case_fold_nfkc($text, $option = 'full')
{
- static $uniarray = array();
static $fc_nfkc_closure = array(
"\xCD\xBA" => "\x20\xCE\xB9",
"\xCF\x92" => "\xCF\x85",
@@ -1649,34 +1653,10 @@ function utf8_case_fold_nfkc($text, $option = 'full')
);
global $phpbb_root_path, $phpEx;
- // common is always set
- if (!isset($uniarray['c']))
- {
- $uniarray['c'] = include($phpbb_root_path . 'includes/utf/data/case_fold_c.' . $phpEx);
- }
-
- // only set full if we need to
- if ($option === 'full' && !isset($uniarray['f']))
- {
- $uniarray['f'] = include($phpbb_root_path . 'includes/utf/data/case_fold_f.' . $phpEx);
- }
-
- // only set simple if we need to
- if ($option !== 'full' && !isset($uniarray['s']))
- {
- $uniarray['s'] = include($phpbb_root_path . 'includes/utf/data/case_fold_s.' . $phpEx);
- }
-
- $text = strtr($text, $uniarray['c']);
- if ($option === 'full')
- {
- $text = strtr($text, $uniarray['f']);
- }
- else
- {
- $text = strtr($text, $uniarray['s']);
- }
+ // do the case fold
+ $text = utf8_case_fold($text, $option);
+ // convert to NFKC
utf_normalizer::nfkc($text);
// FC_NFKC_Closure, http://www.unicode.org/Public/5.0.0/ucd/DerivedNormalizationProps.txt
@@ -1764,36 +1744,11 @@ function utf8_case_fold_nfc($text, $option = 'full')
);
global $phpbb_root_path, $phpEx;
- // common is always set
- if (!isset($uniarray['c']))
- {
- $uniarray['c'] = include($phpbb_root_path . 'includes/utf/data/case_fold_c.' . $phpEx);
- }
-
- // only set full if we need to
- if ($option === 'full' && !isset($uniarray['f']))
- {
- $uniarray['f'] = include($phpbb_root_path . 'includes/utf/data/case_fold_f.' . $phpEx);
- }
-
- // only set simple if we need to
- if ($option !== 'full' && !isset($uniarray['s']))
- {
- $uniarray['s'] = include($phpbb_root_path . 'includes/utf/data/case_fold_s.' . $phpEx);
- }
-
// perform a small trick, avoid further normalization on composed points that contain U+0345 in their decomposition
$text = strtr($text, $ypogegrammeni);
- $text = strtr($text, $uniarray['c']);
- if ($option === 'full')
- {
- $text = strtr($text, $uniarray['f']);
- }
- else
- {
- $text = strtr($text, $uniarray['s']);
- }
+ // do the case fold
+ $text = utf8_case_fold($text, $option);
return $text;
}