diff options
author | David M <davidmj@users.sourceforge.net> | 2006-10-01 08:48:32 +0000 |
---|---|---|
committer | David M <davidmj@users.sourceforge.net> | 2006-10-01 08:48:32 +0000 |
commit | bc15445b58403c92ebca9e23ef3d9a59fbdccc92 (patch) | |
tree | 46880b44be1949f01ada2f29e7f3f42ab4123c1b /phpBB/includes/utf/utf_tools.php | |
parent | bc770de9b93973a359a46ef39838e89f18e685ae (diff) | |
download | forums-bc15445b58403c92ebca9e23ef3d9a59fbdccc92.tar forums-bc15445b58403c92ebca9e23ef3d9a59fbdccc92.tar.gz forums-bc15445b58403c92ebca9e23ef3d9a59fbdccc92.tar.bz2 forums-bc15445b58403c92ebca9e23ef3d9a59fbdccc92.tar.xz forums-bc15445b58403c92ebca9e23ef3d9a59fbdccc92.zip |
- forgot to make the same change to the ODBC driver
- MySQL 3.x works now
- FirebirdSQL is now on the same level as MySQL and PostgreSQL, zero hacks exist inside the core code now
git-svn-id: file:///svn/phpbb/trunk@6422 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/utf/utf_tools.php')
-rw-r--r-- | phpBB/includes/utf/utf_tools.php | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php index 739b939f31..a906cc6ffb 100644 --- a/phpBB/includes/utf/utf_tools.php +++ b/phpBB/includes/utf/utf_tools.php @@ -127,6 +127,9 @@ if (extension_loaded('mbstring')) /** * UTF-8 aware alternative to strrpos * Find position of last occurrence of a char in a string + * + * Notes: + * - offset for mb_strrpos was added in 5.2.0, we emulate if it is lower * * @author Harry Fuecks * @param string haystack @@ -134,10 +137,9 @@ if (extension_loaded('mbstring')) * @param integer (optional) offset (from left) * @return mixed integer position or FALSE on failure */ - function utf8_strrpos($str, $needle, $offset = null) + if (version_compare(phpversion(), '5.2.0', '>=')) { - // offset for mb_strrpos was added in 5.2.0 - if ($offset === false || version_compare(phpversion(), '5.2.0', '>=')) + function utf8_strrpos($str, $needle, $offset = null) { // Emulate behaviour of strrpos rather than raising warning if (empty($str)) @@ -147,22 +149,39 @@ if (extension_loaded('mbstring')) return mb_strrpos($str, $search); } - else + } + else + { + function utf8_strrpos($str, $needle, $offset = null) { - if (!is_int($offset)) + // offset for mb_strrpos was added in 5.2.0 + if ($offset === false) { - trigger_error('utf8_strrpos expects parameter 3 to be long', E_USER_WARNING); - return false; + // Emulate behaviour of strrpos rather than raising warning + if (empty($str)) + { + return false; + } + + return mb_strrpos($str, $search); } + else + { + if (!is_int($offset)) + { + trigger_error('utf8_strrpos expects parameter 3 to be long', E_USER_WARNING); + return false; + } - $str = mb_substr($str, $offset); + $str = mb_substr($str, $offset); - if (false !== ($pos = mb_strrpos($str, $search))) - { - return $pos + $offset; - } + if (false !== ($pos = mb_strrpos($str, $search))) + { + return $pos + $offset; + } - return false; + return false; + } } } |