diff options
author | David M <davidmj@users.sourceforge.net> | 2006-10-07 22:51:55 +0000 |
---|---|---|
committer | David M <davidmj@users.sourceforge.net> | 2006-10-07 22:51:55 +0000 |
commit | 722ab535a67d3193356b851e071cef6fdfa6c40b (patch) | |
tree | e5adb2c16bfde8f710f0e28cb2a800922c3795e4 /phpBB/includes/utf/utf_tools.php | |
parent | 6972d28633abe8aad219af6672d4796f1112aef6 (diff) | |
download | forums-722ab535a67d3193356b851e071cef6fdfa6c40b.tar forums-722ab535a67d3193356b851e071cef6fdfa6c40b.tar.gz forums-722ab535a67d3193356b851e071cef6fdfa6c40b.tar.bz2 forums-722ab535a67d3193356b851e071cef6fdfa6c40b.tar.xz forums-722ab535a67d3193356b851e071cef6fdfa6c40b.zip |
Case folding! :D
git-svn-id: file:///svn/phpbb/trunk@6464 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/utf/utf_tools.php')
-rw-r--r-- | phpBB/includes/utf/utf_tools.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php index 930595b36f..4adb1b2952 100644 --- a/phpBB/includes/utf/utf_tools.php +++ b/phpBB/includes/utf/utf_tools.php @@ -930,4 +930,48 @@ function utf8_from_unicode($array) return $str; } + +/** +* Takes an array of ints representing the Unicode characters and returns +* a UTF-8 string. +* +* @param string $text text to be case folded +* @param string $option determines how we will fold the cases +* @return string case folded text +*/ +function utf8_case_fold($text, $option = 'full') +{ + static $uniarray = array(); + 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']); + } + return $text; +} + ?>
\ No newline at end of file |