From bc15445b58403c92ebca9e23ef3d9a59fbdccc92 Mon Sep 17 00:00:00 2001 From: David M Date: Sun, 1 Oct 2006 08:48:32 +0000 Subject: - 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 --- phpBB/includes/utf/utf_tools.php | 45 ++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'phpBB/includes/utf/utf_tools.php') 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; + } } } -- cgit v1.2.1