From 52ec5467c6fb14156b0ba7a70434d532b3c8d236 Mon Sep 17 00:00:00 2001 From: phpnut Date: Tue, 13 May 2008 04:20:24 +0000 Subject: [PATCH] "Adding new Multibyte Class Adding additional tests Adding some missing casefoldings " git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6833 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/config/unicode/casefolding/0080_00ff.php | 3 +- cake/config/unicode/casefolding/0250_02af.php | 49 + cake/config/unicode/casefolding/0370_03ff.php | 2 +- cake/config/unicode/casefolding/1f00_1fff.php | 2 +- cake/libs/multibyte.php | 1348 +++ cake/tests/cases/libs/multibyte.test.php | 8507 +++++++++++++++++ 6 files changed, 9908 insertions(+), 3 deletions(-) create mode 100644 cake/config/unicode/casefolding/0250_02af.php create mode 100644 cake/libs/multibyte.php create mode 100644 cake/tests/cases/libs/multibyte.test.php diff --git a/cake/config/unicode/casefolding/0080_00ff.php b/cake/config/unicode/casefolding/0080_00ff.php index b7b54fcd6..03521584b 100644 --- a/cake/config/unicode/casefolding/0080_00ff.php +++ b/cake/config/unicode/casefolding/0080_00ff.php @@ -45,7 +45,8 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['0080_00ff'][] = array('upper' => 181, 'status' => 'C', 'lower' => array(956)); /* MICRO SIGN */ +$config['0080_00ff'][] = array('upper' => 181, 'status' => 'C', 'lower' => array(956)); +$config['0080_00ff'][] = array('upper' => 924, 'status' => 'C', 'lower' => array(181)); $config['0080_00ff'][] = array('upper' => 192, 'status' => 'C', 'lower' => array(224)); /* LATIN CAPITAL LETTER A WITH GRAVE */ $config['0080_00ff'][] = array('upper' => 193, 'status' => 'C', 'lower' => array(225)); /* LATIN CAPITAL LETTER A WITH ACUTE */ $config['0080_00ff'][] = array('upper' => 194, 'status' => 'C', 'lower' => array(226)); /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */ diff --git a/cake/config/unicode/casefolding/0250_02af.php b/cake/config/unicode/casefolding/0250_02af.php new file mode 100644 index 000000000..1b7c28f58 --- /dev/null +++ b/cake/config/unicode/casefolding/0250_02af.php @@ -0,0 +1,49 @@ + + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.config.unicode.casefolding + * @since CakePHP(tm) v 1.2.0.6833 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +/** + * The upper field is the decimal value of the upper case character + * + * The lower filed is an array of the decimal values that form the lower case version of a character. + * + * The status field is: + * C: common case folding, common mappings shared by both simple and full mappings. + * F: full case folding, mappings that cause strings to grow in length. Multiple characters are separated by spaces. + * S: simple case folding, mappings to single characters where different from F. + * T: special case for uppercase I and dotted uppercase I + * - For non-Turkic languages, this mapping is normally not used. + * - For Turkic languages (tr, az), this mapping can be used instead of the normal mapping for these characters. + * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. + * See the discussions of case mapping in the Unicode Standard for more information. + */ +$config['0250_02af'][] = array('upper' => 422, 'status' => 'C', 'lower' => array(640)); +?> \ No newline at end of file diff --git a/cake/config/unicode/casefolding/0370_03ff.php b/cake/config/unicode/casefolding/0370_03ff.php index 4f0cd9914..eaec95258 100644 --- a/cake/config/unicode/casefolding/0370_03ff.php +++ b/cake/config/unicode/casefolding/0370_03ff.php @@ -52,7 +52,7 @@ $config['0370_03ff'][] = array('upper' => 906, 'status' => 'C', 'lower' => array $config['0370_03ff'][] = array('upper' => 908, 'status' => 'C', 'lower' => array(972)); /* GREEK CAPITAL LETTER OMICRON WITH TONOS */ $config['0370_03ff'][] = array('upper' => 910, 'status' => 'C', 'lower' => array(973)); /* GREEK CAPITAL LETTER UPSILON WITH TONOS */ $config['0370_03ff'][] = array('upper' => 911, 'status' => 'C', 'lower' => array(974)); /* GREEK CAPITAL LETTER OMEGA WITH TONOS */ -$config['0370_03ff'][] = array('upper' => 912, 'status' => 'F', 'lower' => array(953, 776, 769)); /* GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS */ +//$config['0370_03ff'][] = array('upper' => 912, 'status' => 'F', 'lower' => array(953, 776, 769)); /* GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS */ $config['0370_03ff'][] = array('upper' => 913, 'status' => 'C', 'lower' => array(945)); /* GREEK CAPITAL LETTER ALPHA */ $config['0370_03ff'][] = array('upper' => 914, 'status' => 'C', 'lower' => array(946)); /* GREEK CAPITAL LETTER BETA */ $config['0370_03ff'][] = array('upper' => 915, 'status' => 'C', 'lower' => array(947)); /* GREEK CAPITAL LETTER GAMMA */ diff --git a/cake/config/unicode/casefolding/1f00_1fff.php b/cake/config/unicode/casefolding/1f00_1fff.php index f73e03ea0..fe9ed38ab 100644 --- a/cake/config/unicode/casefolding/1f00_1fff.php +++ b/cake/config/unicode/casefolding/1f00_1fff.php @@ -45,7 +45,7 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['1f00_1fff'][] = array('upper' => 7944, 'status' => 'C', 'lower' => array(7936)); /* GREEK CAPITAL LETTER ALPHA WITH PSILI */ +$config['1f00_1fff'][] = array('upper' => 7944, 'status' => 'C', 'lower' => array(7936, 953)); /* GREEK CAPITAL LETTER ALPHA WITH PSILI */ $config['1f00_1fff'][] = array('upper' => 7945, 'status' => 'C', 'lower' => array(7937)); /* GREEK CAPITAL LETTER ALPHA WITH DASIA */ $config['1f00_1fff'][] = array('upper' => 7946, 'status' => 'C', 'lower' => array(7938)); /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA */ $config['1f00_1fff'][] = array('upper' => 7947, 'status' => 'C', 'lower' => array(7939)); /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA */ diff --git a/cake/libs/multibyte.php b/cake/libs/multibyte.php new file mode 100644 index 000000000..28cf96331 --- /dev/null +++ b/cake/libs/multibyte.php @@ -0,0 +1,1348 @@ + + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The MIT License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project + * @package cake + * @subpackage cake.cake.libs + * @since CakePHP(tm) v 1.2.0.6833 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/mit-license.php The MIT License + */ +if (function_exists('mb_internal_encoding')) { + mb_internal_encoding(Configure::read('App.encoding')); +} +/** + * Find position of first occurrence of a case-insensitive string. + * + * @param string $haystack The string from which to get the position of the first occurrence of $needle. + * @param string $needle The string to find in $haystack. + * @param integer $offset The position in $haystack to start searching. + * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. + * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string, or false if $needle is not found. + */ +if (!function_exists('mb_stripos')) { + function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { + return Multibyte::stripos($haystack, $needle, $offset); + } +} +/** + * Finds first occurrence of a string within another, case insensitive. + * + * @param string $haystack The string from which to get the first occurrence of $needle. + * @param string $needle The string to find in $haystack. + * @param boolean $part Determines which portion of $haystack this function returns. + * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. + * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, Default value is false. + * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. + * @return string|boolean The portion of $haystack, or false if $needle is not found. + */ +if (!function_exists('mb_stristr')) { + function mb_stristr($haystack, $needle, $part = false, $encoding = null) { + return Multibyte::stristr($haystack, $needle, $part); + } +} +/** + * Get string length. + * + * @param string $string The string being checked for length. + * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. + * @return integer The number of characters in string $string having character encoding encoding. + * A multi-byte character is counted as 1. + */ +if (!function_exists('mb_strlen')) { + function mb_strlen($string, $encoding = null) { + return Multibyte::strlen($string); + } +} +/** + * Find position of first occurrence of a string. + * + * @param string $haystack The string being checked. + * @param string $needle The position counted from the beginning of haystack. + * @param integer $offset The search offset. If it is not specified, 0 is used. + * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. + * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string. + * If $needle is not found, it returns false. + */ +if (!function_exists('mb_strpos')) { + function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { + return Multibyte::strpos($haystack, $needle, $offset); + } +} +/** + * Finds the last occurrence of a character in a string within another. + * + * @param string $haystack The string from which to get the last occurrence of $needle. + * @param string $needle The string to find in $haystack. + * @param boolean $part Determines which portion of $haystack this function returns. + * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. + * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, Default value is false. + * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. + * @return string|boolean The portion of $haystack. or false if $needle is not found. + */ +if (!function_exists('mb_strrchr')) { + function mb_strrchr($haystack, $needle, $part = false, $encoding = null) { + return Multibyte::strrchr($haystack, $needle, $part); + } +} +/** + * Finds the last occurrence of a character in a string within another, case insensitive. + * + * @param string $haystack The string from which to get the last occurrence of $needle. + * @param string $needle The string to find in $haystack. + * @param boolean $part Determines which portion of $haystack this function returns. + * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. + * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, Default value is false. + * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. + * @return string|boolean The portion of $haystack. or false if $needle is not found. + */ +if (!function_exists('mb_strrichr')) { + function mb_strrichr($haystack, $needle, $part = false, $encoding = null) { + return Multibyte::strrichr($haystack, $needle, $part); + } +} +/** + * Finds position of last occurrence of a string within another, case insensitive + * + * @param string $haystack The string from which to get the position of the last occurrence of $needle. + * @param string $needle The string to find in $haystack. + * @param integer $offset The position in $haystack to start searching. + * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. + * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string, or false if $needle is not found. + */ +if (!function_exists('mb_strripos')) { + function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { + return Multibyte::strripos($haystack, $needle, $offset); + } +} +/** + * Find position of last occurrence of a string in a string. + * + * @param string $haystack The string being checked, for the last occurrence of $needle. + * @param string $needle The string to find in $haystack. + * @param integer $offset May be specified to begin searching an arbitrary number of characters into the string. + * Negative values will stop searching at an arbitrary point prior to the end of the string. + * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. + * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string. If $needle is not found, it returns false. + */ +if (!function_exists('mb_strrpos')) { + function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { + return Multibyte::strrpos($haystack, $needle, $offset); + } +} +/** + * Finds first occurrence of a string within another + * + * @param string $haystack The string from which to get the first occurrence of $needle. + * @param string $needle The string to find in $haystack + * @param boolean $part Determines which portion of $haystack this function returns. + * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. + * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, Default value is FALSE. + * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. + * @return string|boolean The portion of $haystack, or true if $needle is not found. + */ +if (!function_exists('mb_strstr')) { + function mb_strstr($haystack, $needle, $part = false, $encoding = null) { + return Multibyte::strstr($haystack, $needle, $part); + } +} +/** + * Make a string lowercase + * + * @param string $string The string being lowercased. + * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. + * @return string with all alphabetic characters converted to lowercase. + */ +if (!function_exists('mb_strtolower')) { + function mb_strtolower($string, $encoding = null) { + return Multibyte::strtolower($string); + } +} +/** + * Make a string uppercase + * + * @param string $string The string being uppercased. + * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. + * @return string with all alphabetic characters converted to uppercase. + */ +if (!function_exists('mb_strtoupper')) { + function mb_strtoupper($string, $encoding = null) { + return Multibyte::strtoupper($string); + } +} +/** + * Count the number of substring occurrences + * + * @param string $haystack The string being checked. + * @param string $needle The string being found. + * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. + * @return integer The number of times the $needle substring occurs in the $haystack string. + */ +if (!function_exists('mb_substr_count')) { + function mb_substr_count($haystack, $needle, $encoding = null) { + return Multibyte::substrCount($haystack, $needle); + } +} +/** + * Get part of string + * + * @param string $string The string being checked. + * @param integer $start The first position used in $string. + * @param integer $length The maximum length of the returned string. + * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. + * @return string The portion of $string specified by the $string and $length parameters. + * @access public + * @static + */ +if (!function_exists('mb_substr')) { + function mb_substr($string, $start, $length = null, $encoding = null) { + return Multibyte::substr($string, $start, $length); + } +} +/** + * Multibyte handling methods. + * + * + * @package cake + * @subpackage cake.cake.libs + */ +class Multibyte extends Object { +/** + * Holds the decimal value of a multi-byte character + * + * @var array + * @access private + */ + var $__utf8Map = array(); +/** + * Holds the case folding values + * + * @var array + * @access private + */ + var $__caseFold = array(); +/** + * Holds an array of Unicode code point ranges + * + * @var array + * @access private + */ + var $__codeRange = array(); +/** + * Holds the current code point range + * + * @var string + * @access private + */ + var $__table = null; +/** + * Gets a reference to the Multibyte object instance + * + * @return object Multibyte instance + * @access public + * @static + */ + function &getInstance() { + static $instance = array(); + + if (!isset($instance[0]) || !$instance[0]) { + $instance[0] =& new Multibyte(); + } + return $instance[0]; + } +/** + * Converts a multibyte character string + * to the decimal value of the character + * + * @param multibyte string $string + * @return array + * @access public + * @static + */ + function utf8($string) { + $_this =& Multibyte::getInstance(); + $_this->__reset(); + + $values = array(); + $find = 1; + $length = strlen($string); + + for ($i = 0; $i < $length; $i++ ) { + $value = ord(($string[$i])); + + if ($value < 128) { + $_this->__utf8Map[] = $value; + + } else { + if (count($values) == 0) { + $find = ife($value < 224, 2, 3); + } + $values[] = $value; + + if (count($values) === $find) { + if ($find == 3) { + $_this->__utf8Map[] = (($values[0] % 16) * 4096) + (($values[1] % 64) * 64) + ($values[2] % 64); + + } else { + $_this->__utf8Map[] = (($values[0] % 32) * 64) + ($values[1] % 64); + + } + $values = array(); + $find = 1; + } + } + } + return $_this->__utf8Map; + } +/** + * Converts the decimal value of a multibyte character string + * to a string + * + * @param array $array + * @return string + * @access public + * @static + */ + function ascii($array) { + $ascii = ''; + + foreach($array as $utf8) { + if ($utf8 < 128) { + $ascii .= chr($utf8); + + } elseif ($utf8 < 2048) { + $ascii .= chr(192 + (($utf8 - ($utf8 % 64)) / 64)); + $ascii .= chr(128 + ($utf8 % 64)); + } else { + $ascii .= chr(224 + (($utf8 - ($utf8 % 4096)) / 4096)); + $ascii .= chr(128 + ((($utf8 % 4096) - ($utf8 % 64)) / 64)); + $ascii .= chr(128 + ($utf8 % 64)); + } + } + return $ascii; + } +/** + * Find position of first occurrence of a case-insensitive string. + * + * @param multi-byte string $haystack The string from which to get the position of the first occurrence of $needle. + * @param multi-byte string $needle The string to find in $haystack. + * @param integer $offset The position in $haystack to start searching. + * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string, or false if $needle is not found. + * @access public + * @static + */ + function stripos($haystack, $needle, $offset = 0) { + $_this =& Multibyte::getInstance(); + + if (!PHP5 || $_this->__checkMultibyte($haystack)) { + $haystack = $_this->strtoupper($haystack); + $needle = $_this->strtoupper($needle); + return $_this->strpos($haystack, $needle, $offset); + } + return stripos($haystack, $needle, $offset); + } +/** + * Finds first occurrence of a string within another, case insensitive. + * + * @param string $haystack The string from which to get the first occurrence of $needle. + * @param string $needle The string to find in $haystack. + * @param boolean $part Determines which portion of $haystack this function returns. + * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. + * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, Default value is false. + * @return int|boolean The portion of $haystack, or false if $needle is not found. + * @access public + * @static + */ + function stristr($haystack, $needle, $part = false) { + $_this =& Multibyte::getInstance(); + $php = (phpversion() < 5.3); + + if (($php && $part) || $_this->__checkMultibyte($haystack)) { + $check = $_this->strtoupper($haystack); + $check = $_this->utf8($check); + $found = false; + $haystack = $_this->utf8($haystack); + $haystackCount = count($haystack); + $needle = $_this->strtoupper($needle); + $needle = $_this->utf8($needle); + $needleCount = count($needle); + $parts = array(); + $position = 0; + + while (($found === false) && ($position < $haystackCount)) { + if (isset($needle[0]) && $needle[0] === $check[$position]) { + for ($i = 1; $i < $needleCount; $i++) { + if ($needle[$i] !== $check[$position + $i]) { + break; + } + } + if ($i === $needleCount) { + $found = true; + } + } + if (!$found) { + $parts[] = $haystack[$position]; + unset($haystack[$position]); + } + $position++; + } + + if ($found && $part && !empty($parts)) { + return $_this->ascii($parts); + } elseif ($found && !empty($haystack)) { + return $_this->ascii($haystack); + } + return false; + } + + if (!$php) { + return stristr($haystack, $needle, $part); + } + return stristr($haystack, $needle); + } +/** + * Get string length. + * + * @param string $string The string being checked for length. + * @return integer The number of characters in string $string + * @access public + * @static + */ + function strlen($string) { + $_this =& Multibyte::getInstance(); + if ($_this->__checkMultibyte($string)) { + $string = $_this->utf8($string); + return count($string); + } + return strlen($string); + } +/** + * Find position of first occurrence of a string. + * + * @param string $haystack The string being checked. + * @param string $needle The position counted from the beginning of haystack. + * @param integer $offset The search offset. If it is not specified, 0 is used. + * @return integer|boolean The numeric position of the first occurrence of $needle in the $haystack string. + * If $needle is not found, it returns false. + * @access public + * @static + */ + function strpos($haystack, $needle, $offset = 0) { + $_this =& Multibyte::getInstance(); + + if ($_this->__checkMultibyte($haystack)) { + $found = false; + $haystack = $_this->utf8($haystack); + $haystackCount = count($haystack); + $needle = $_this->utf8($needle); + $needleCount = count($needle); + $position = $offset; + + while (($found === false) && ($position < $haystackCount)) { + if (isset($needle[0]) && $needle[0] === $haystack[$position]) { + for ($i = 1; $i < $needleCount; $i++) { + if ($needle[$i] !== $haystack[$position + $i]) { + break; + } + } + if ($i === $needleCount) { + $found = true; + $position--; + } + } + $position++; + } + if ($found) { + return $position; + } + return false; + } + return strpos($haystack, $needle, $offset); + } +/** + * Finds the last occurrence of a character in a string within another. + * + * @param string $haystack The string from which to get the last occurrence of $needle. + * @param string $needle The string to find in $haystack. + * @param boolean $part Determines which portion of $haystack this function returns. + * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. + * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, Default value is false. + * @return string|boolean The portion of $haystack. or false if $needle is not found. + * @access public + * @static + */ + function strrchr($haystack, $needle, $part = false) { + $_this =& Multibyte::getInstance(); + + $check = $_this->utf8($haystack); + $found = false; + $haystack = $_this->utf8($haystack); + $haystackCount = count($haystack); + $matches = array_count_values($check); + $needle = $_this->utf8($needle); + $needleCount = count($needle); + $parts = array(); + $position = 0; + + while (($found === false) && ($position < $haystackCount)) { + if (isset($needle[0]) && $needle[0] === $check[$position]) { + for ($i = 1; $i < $needleCount; $i++) { + if ($needle[$i] !== $check[$position + $i]) { + if ($needle[$i] === $check[($position + $i) -1]) { + $found = true; + } + unset($parts[$position - 1]); + $haystack = array_merge(array($haystack[$position]), $haystack); + break; + } + } + if (isset($matches[$needle[0]]) && $matches[$needle[0]] > 1) { + $matches[$needle[0]] = $matches[$needle[0]] - 1; + } elseif ($i === $needleCount) { + $found = true; + } + } + + if (!$found && isset($haystack[$position])) { + $parts[] = $haystack[$position]; + unset($haystack[$position]); + } + $position++; + } + + if ($found && $part && !empty($parts)) { + return $_this->ascii($parts); + } elseif ($found && !empty($haystack)) { + return $_this->ascii($haystack); + } + return false; + } +/** + * Finds the last occurrence of a character in a string within another, case insensitive. + * + * @param string $haystack The string from which to get the last occurrence of $needle. + * @param string $needle The string to find in $haystack. + * @param boolean $part Determines which portion of $haystack this function returns. + * If set to true, it returns all of $haystack from the beginning to the last occurrence of $needle. + * If set to false, it returns all of $haystack from the last occurrence of $needle to the end, Default value is false. + * @return string|boolean The portion of $haystack. or false if $needle is not found. + * @access public + * @static + */ + function strrichr($haystack, $needle, $part = false) { + $_this =& Multibyte::getInstance(); + + $check = $_this->strtoupper($haystack); + $check = $_this->utf8($check); + $found = false; + $haystack = $_this->utf8($haystack); + $haystackCount = count($haystack); + $matches = array_count_values($check); + $needle = $_this->strtoupper($needle); + $needle = $_this->utf8($needle); + $needleCount = count($needle); + $parts = array(); + $position = 0; + + while (($found === false) && ($position < $haystackCount)) { + if (isset($needle[0]) && $needle[0] === $check[$position]) { + for ($i = 1; $i < $needleCount; $i++) { + if ($needle[$i] !== $check[$position + $i]) { + if ($needle[$i] === $check[($position + $i) -1]) { + $found = true; + } + unset($parts[$position - 1]); + $haystack = array_merge(array($haystack[$position]), $haystack); + break; + } + } + if (isset($matches[$needle[0]]) && $matches[$needle[0]] > 1) { + $matches[$needle[0]] = $matches[$needle[0]] - 1; + } elseif ($i === $needleCount) { + $found = true; + } + } + + if (!$found && isset($haystack[$position])) { + $parts[] = $haystack[$position]; + unset($haystack[$position]); + } + $position++; + } + + if ($found && $part && !empty($parts)) { + return $_this->ascii($parts); + } elseif ($found && !empty($haystack)) { + return $_this->ascii($haystack); + } + return false; + } +/** + * Finds position of last occurrence of a string within another, case insensitive + * + * @param string $haystack The string from which to get the position of the last occurrence of $needle. + * @param string $needle The string to find in $haystack. + * @param integer $offset The position in $haystack to start searching. + * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string, or false if $needle is not found. + * @access public + * @static + */ + function strripos($haystack, $needle, $offset = 0) { + $_this =& Multibyte::getInstance(); + + if (!PHP5 || $_this->__checkMultibyte($haystack)) { + $found = false; + $haystack = $_this->strtoupper($haystack); + $haystack = $_this->utf8($haystack); + $haystackCount = count($haystack); + $matches = array_count_values($haystack); + $needle = $_this->strtoupper($needle); + $needle = $_this->utf8($needle); + $needleCount = count($needle); + $position = $offset; + + while (($found === false) && ($position < $haystackCount)) { + if (isset($needle[0]) && $needle[0] === $haystack[$position]) { + for ($i = 1; $i < $needleCount; $i++) { + if ($needle[$i] !== $haystack[$position + $i]) { + if ($needle[$i] === $haystack[($position + $i) -1]) { + $position--; + $found = true; + continue; + } + } + } + + if (!$offset && isset($matches[$needle[0]]) && $matches[$needle[0]] > 1) { + $matches[$needle[0]] = $matches[$needle[0]] - 1; + } elseif ($i === $needleCount) { + $found = true; + $position--; + } + } + $position++; + } + $return = ife($found, $position, false); + return $return; + } + return strripos($haystack, $needle, $offset); + } + +/** + * Find position of last occurrence of a string in a string. + * + * @param string $haystack The string being checked, for the last occurrence of $needle. + * @param string $needle The string to find in $haystack. + * @param integer $offset May be specified to begin searching an arbitrary number of characters into the string. + * Negative values will stop searching at an arbitrary point prior to the end of the string. + * @return integer|boolean The numeric position of the last occurrence of $needle in the $haystack string. If $needle is not found, it returns false. + * @access public + * @static + */ + function strrpos($haystack, $needle, $offset = 0) { + $_this =& Multibyte::getInstance(); + + if (!PHP5 || $_this->__checkMultibyte($haystack)) { + $found = false; + $haystack = $_this->utf8($haystack); + $haystackCount = count($haystack); + $matches = array_count_values($haystack); + $needle = $_this->utf8($needle); + $needleCount = count($needle); + $position = $offset; + + while (($found === false) && ($position < $haystackCount)) { + if (isset($needle[0]) && $needle[0] === $haystack[$position]) { + for ($i = 1; $i < $needleCount; $i++) { + if ($needle[$i] !== $haystack[$position + $i]) { + if ($needle[$i] === $haystack[($position + $i) -1]) { + $position--; + $found = true; + continue; + } + } + } + + if (!$offset && isset($matches[$needle[0]]) && $matches[$needle[0]] > 1) { + $matches[$needle[0]] = $matches[$needle[0]] - 1; + } elseif ($i === $needleCount) { + $found = true; + $position--; + } + } + $position++; + } + $return = ife($found, $position, false); + return $return; + } + return strrpos($haystack, $needle, $offset); + } +/** + * Finds first occurrence of a string within another + * + * @param string $haystack The string from which to get the first occurrence of $needle. + * @param string $needle The string to find in $haystack + * @param boolean $part Determines which portion of $haystack this function returns. + * If set to true, it returns all of $haystack from the beginning to the first occurrence of $needle. + * If set to false, it returns all of $haystack from the first occurrence of $needle to the end, Default value is FALSE. + * @return string|boolean The portion of $haystack, or true if $needle is not found. + * @access public + * @static + */ + function strstr($haystack, $needle, $part = false) { + $_this =& Multibyte::getInstance(); + $php = (phpversion() < 5.3); + + if (($php && $part) || $_this->__checkMultibyte($haystack)) { + $check = $_this->utf8($haystack); + $found = false; + $haystack = $_this->utf8($haystack); + $haystackCount = count($haystack); + $needle = $_this->utf8($needle); + $needleCount = count($needle); + $parts = array(); + $position = 0; + + while (($found === false) && ($position < $haystackCount)) { + if (isset($needle[0]) && $needle[0] === $check[$position]) { + for ($i = 1; $i < $needleCount; $i++) { + if ($needle[$i] !== $check[$position + $i]) { + break; + } + } + if ($i === $needleCount) { + $found = true; + } + } + if (!$found) { + $parts[] = $haystack[$position]; + unset($haystack[$position]); + } + $position++; + } + + if ($found && $part && !empty($parts)) { + return $_this->ascii($parts); + } elseif ($found && !empty($haystack)) { + return $_this->ascii($haystack); + } + return false; + } + + if (!$php) { + return strstr($haystack, $needle, $part); + } + return strstr($haystack, $needle); + } +/** + * Make a string lowercase + * + * @param string $string The string being lowercased. + * @return string with all alphabetic characters converted to lowercase. + * @access public + * @static + */ + function strtolower($string) { + $_this =& Multibyte::getInstance(); + $_this->utf8($string); + + $length = count($_this->__utf8Map); + $lowerCase = array(); + $matched = false; + + for ($i = 0 ; $i < $length; $i++) { + $char = $_this->__utf8Map[$i]; + + if ($char < 128) { + $str = strtolower(chr($char)); + $strlen = strlen($str); + for ($ii = 0 ; $ii < $strlen; $ii++) { + $lower = ord(substr($str, $ii, 1)); + } + $lowerCase[] = $lower; + $matched = true; + + } else { + $matched = false; + $keys = $_this->__find($char, 'upper'); + + if (!empty($keys)) { + foreach ($keys as $key => $value) { + if ($keys[$key]['upper'] == $char && count($keys[$key]['lower'][0]) === 1) { + $lowerCase[] = $keys[$key]['lower'][0]; + $matched = true; + break 1; + } + } + } + } + if ($matched === false) { + $lowerCase[] = $char; + } + } + return $_this->ascii($lowerCase); + } +/** + * Make a string uppercase + * + * @param string $string The string being uppercased. + * @param string $encoding Character encoding name to use. If it is omitted, internal character encoding is used. + * @return string with all alphabetic characters converted to uppercase. + * @access public + * @static + */ + function strtoupper($string) { + $_this =& Multibyte::getInstance(); + $_this->utf8($string); + + $length = count($_this->__utf8Map); + $matched = false; + $replaced = array(); + $upperCase = array(); + + for ($i = 0 ; $i < $length; $i++) { + $char = $_this->__utf8Map[$i]; + + if ($char < 128) { + $str = strtoupper(chr($char)); + $strlen = strlen($str); + for ($ii = 0 ; $ii < $strlen; $ii++) { + $upper = ord(substr($str, $ii, 1)); + } + $upperCase[] = $upper; + $matched = true; + + } else { + $matched = false; + $keys = $_this->__find($char); + $keyCount = count($keys); + + if (!empty($keys)) { + foreach ($keys as $key => $value) { + $matched = false; + $replace = 0; + if ($length > 1 && count($keys[$key]['lower']) > 1) { + $j = 0; + + for ($ii = 0; $ii < count($keys[$key]['lower']); $ii++) { + $nextChar = $_this->__utf8Map[$i + $ii]; + + if (isset($nextChar) && ($nextChar == $keys[$key]['lower'][$j + $ii])) { + $replace++; + } + } + if ($replace == count($keys[$key]['lower'])) { + $upperCase[] = $keys[$key]['upper']; + $replaced = array_merge($replaced, array_values($keys[$key]['lower'])); + $matched = true; + break 1; + } + } elseif ($length > 1 && $keyCount > 1) { + $j = 0; + for ($ii = 1; $ii < $keyCount; $ii++) { + $nextChar = $_this->__utf8Map[$i + $ii - 1]; + + if (in_array($nextChar, $keys[$ii]['lower'])) { + + for ($jj = 0; $jj < count($keys[$ii]['lower']); $jj++) { + $nextChar = $_this->__utf8Map[$i + $jj]; + + if (isset($nextChar) && ($nextChar == $keys[$ii]['lower'][$j + $jj])) { + $replace++; + } + } + if ($replace == count($keys[$ii]['lower'])) { + $upperCase[] = $keys[$ii]['upper']; + $replaced = array_merge($replaced, array_values($keys[$ii]['lower'])); + $matched = true; + break 2; + } + } + } + } + if ($keys[$key]['lower'][0] == $char) { + $upperCase[] = $keys[$key]['upper']; + $matched = true; + break 1; + } + } + } + } + if ($matched === false && !in_array($char, $replaced, true)) { + $upperCase[] = $char; + } + } + return $_this->ascii($upperCase); + } +/** + * Count the number of substring occurrences + * + * @param string $haystack The string being checked. + * @param string $needle The string being found. + * @return integer The number of times the $needle substring occurs in the $haystack string. + * @access public + * @static + */ + function substrCount($haystack, $needle) { + $_this =& Multibyte::getInstance(); + + $count = 0; + $haystack = $_this->utf8($haystack); + $haystackCount = count($haystack); + $matches = array_count_values($haystack); + $needle = $_this->utf8($needle); + $needleCount = count($needle); + + if ($needleCount === 1 && isset($matches[$needle[0]])) { + return $matches[$needle[0]]; + } + + for ($i = 0; $i < $haystackCount; $i++) { + if (isset($needle[0]) && $needle[0] === $haystack[$i]) { + for ($ii = 1; $ii < $needleCount; $ii++) { + if ($needle[$ii] === $haystack[$i + 1]) { + if ((isset($needle[$ii + 1]) && $haystack[$i + 2]) && $needle[$ii + 1] !== $haystack[$i + 2]) { + $count--; + } else { + $count++; + } + } + } + } + } + return $count; + } +/** + * Get part of string + * + * @param string $string The string being checked. + * @param integer $start The first position used in $string. + * @param integer $length The maximum length of the returned string. + * @return string The portion of $string specified by the $string and $length parameters. + * @access public + * @static + */ + function substr($string, $start, $length = null) { + if ($start === 0 && $length === null) { + return $string; + } + $_this =& Multibyte::getInstance(); + + $string = $_this->utf8($string); + $stringCount = count($string); + + for ($i = 1; $i <= $start; $i++) { + unset($string[$i - 1]); + } + + if ($length === null || count($string) < $length) { + return $_this->ascii($string); + } + $string = array_values($string); + + for ($i = 0; $i < $length; $i++) { + $value[] = $string[$i]; + } + return $_this->ascii($value); + } +/** + * Return the Code points range for Unicode characters + * + * @param interger $decimal + * @return string + * @access private + */ + function __codepoint ($decimal) { + $_this =& Multibyte::getInstance(); + + if ($decimal < 128) { + $return = '0000_007f'; // Basic Latin + } elseif ($decimal < 256) { + $return = '0080_00ff'; // Latin-1 Supplement + } elseif ($decimal < 384) { + $return = '0100_017f'; // Latin Extended-A + } elseif ($decimal < 592) { + $return = '0180_024F'; // Latin Extended-B + } elseif ($decimal < 688) { + $return = '0250_02af'; // IPA Extensions + } elseif ($decimal < 768) { + $return = '02b0_02ff'; // Spacing Modifier Letters + } elseif ($decimal < 880) { + $return = '0300_036f'; // Combining Diacritical Marks + } elseif ($decimal < 1024) { + $return = '0370_03ff'; // Greek and Coptic + } elseif ($decimal < 1280) { + $return = '0400_04ff'; // Cyrillic + } elseif ($decimal < 1328) { + $return = '0500_052f'; // Cyrillic Supplement + } elseif ($decimal < 1424) { + $return = '0530_058f'; // Armenian + } elseif ($decimal < 1536) { + $return = '0590_05ff'; // Hebrew + } elseif ($decimal < 1792) { + $return = '0600_06ff'; // Arabic + } elseif ($decimal < 1872) { + $return = '0700_074f'; // Syriac + } elseif ($decimal < 1920) { + $return = '0750_077f'; // Arabic Supplement + } elseif ($decimal < 1984) { + $return = '0780_07bf'; // Thaana + } elseif ($decimal < 2304) { + $return = '07c0_07ff'; // NKo + } elseif ($decimal < 2432) { + $return = '0900_097f'; // Devanagari + } elseif ($decimal < 2560) { + $return = '0980_09ff'; // Bengali + } elseif ($decimal < 2688) { + $return = '0a00_0a7f'; // Gurmukhi + } elseif ($decimal < 2816) { + $return = '0a80_0aff'; // Gujarati + } elseif ($decimal < 2944) { + $return = '0b00_0b7f'; // Oriya + } elseif ($decimal < 3072) { + $return = '0b80_0bff'; // Tamil + } elseif ($decimal < 3200) { + $return = '0c00_0c7f'; // Telugu + } elseif ($decimal < 3328) { + $return = '0c80_0cff'; // Kannada + } elseif ($decimal < 3456) { + $return = '0d00_0d7f'; // Malayalam + } elseif ($decimal < 3584) { + $return = '0d80_0dff'; // Sinhala + } elseif ($decimal < 3712) { + $return = '0e00_0e7f'; // Thai + } elseif ($decimal < 3840) { + $return = '0e80_0eff'; // Lao + } elseif ($decimal < 4096) { + $return = '0f00_0fff'; // Tibetan + } elseif ($decimal < 4256) { + $return = '1000_109f'; // Myanmar + } elseif ($decimal < 4352) { + $return = '10a0_10ff'; // Georgian + } elseif ($decimal < 4608) { + $return = '1100_11ff'; // Hangul Jamo + } elseif ($decimal < 4992) { + $return = '1200_137f'; // Ethiopic + } elseif ($decimal < 5024) { + $return = '1380_139f'; // Ethiopic Supplement + } elseif ($decimal < 5120) { + $return = '13a0_13ff'; // Cherokee + } elseif ($decimal < 5760) { + $return = '1400_167f'; // Unified Canadian Aboriginal Syllabics + } elseif ($decimal < 5792) { + $return = '1680_169f'; // Ogham + } elseif ($decimal < 5888) { + $return = '16a0_16ff'; // Runic + } elseif ($decimal < 5920) { + $return = '1700_171f'; // Tagalog + } elseif ($decimal < 5952) { + $return = '1720_173f'; // Hanunoo + } elseif ($decimal < 5984) { + $return = '1740_175f'; // Buhid + } elseif ($decimal < 6016) { + $return = '1760_177f'; // Tagbanwa + } elseif ($decimal < 6144) { + $return = '1780_17ff'; // Khmer + } elseif ($decimal < 6400) { + $return = '1800_18af'; // Mongolian + } elseif ($decimal < 6480) { + $return = '1900_194f'; // Limbu + } elseif ($decimal < 6528) { + $return = '1950_197f'; // Tai Le + } elseif ($decimal < 6624) { + $return = '1980_19df'; // New Tai Lue + } elseif ($decimal < 6656) { + $return = '19e0_19ff'; // Khmer Symbols + } elseif ($decimal < 6912) { + $return = '1a00_1a1f'; // Buginese + } elseif ($decimal < 7424) { + $return = '1b00_1b7f'; // Balinese + } elseif ($decimal < 7552) { + $return = '1d00_1d7f'; // Phonetic Extensions + } elseif ($decimal < 7616) { + $return = '1d80_1dbf'; // Phonetic Extensions Supplement + } elseif ($decimal < 7680) { + $return = '1dc0_1dff'; // Combining Diacritical Marks Supplement + } elseif ($decimal < 7936) { + $return = '1e00_1eff'; // Latin Extended Additional + } elseif ($decimal < 8192) { + $return = '1f00_1fff'; // Greek Extended + } elseif ($decimal < 8304) { + $return = '2000_206f'; // General Punctuation + } elseif ($decimal < 8352) { + $return = '2070_209f'; // Superscripts and Subscripts + } elseif ($decimal < 8400) { + $return = '20a0_20cf'; // Currency Symbols + } elseif ($decimal < 8448) { + $return = '20d0_20ff'; // Combining Diacritical Marks for Symbols + } elseif ($decimal < 8528) { + $return = '2100_214f'; // Letterlike Symbols + } elseif ($decimal < 8592) { + $return = '2150_218f'; // Number Forms + } elseif ($decimal < 8704) { + $return = '2190_21ff'; // Arrows + } elseif ($decimal < 8960) { + $return = '2200_22ff'; // Mathematical Operators + } elseif ($decimal < 9216) { + $return = '2300_23ff'; // Miscellaneous Technical + } elseif ($decimal < 9280) { + $return = '2400_243f'; // Control Pictures + } elseif ($decimal < 9312) { + $return = '2440_245f'; // Optical Character Recognition + } elseif ($decimal < 9472) { + $return = '2460_24ff'; // Enclosed Alphanumerics + } elseif ($decimal < 9600) { + $return = '2500_257f'; // Box Drawing + } elseif ($decimal < 9632) { + $return = '2580_259f'; // Block Elements + } elseif ($decimal < 9728) { + $return = '25a0_25ff'; // Geometric Shapes + } elseif ($decimal < 9984) { + $return = '2600_26ff'; // Miscellaneous Symbols + } elseif ($decimal < 10176) { + $return = '2700_27bf'; // Dingbats + } elseif ($decimal < 10224) { + $return = '27c0_27ef'; // Miscellaneous Mathematical Symbols-A + } elseif ($decimal < 10240) { + $return = '27f0_27ff'; // Supplemental Arrows-A + } elseif ($decimal < 10496) { + $return = '2800_28ff'; // Braille Patterns + } elseif ($decimal < 10624) { + $return = '2900_297f'; // Supplemental Arrows-B + } elseif ($decimal < 10752) { + $return = '2980_29ff'; // Miscellaneous Mathematical Symbols-B + } elseif ($decimal < 11008) { + $return = '2a00_2aff'; // Supplemental Mathematical Operators + } elseif ($decimal < 11264) { + $return = '2b00_2bff'; // Miscellaneous Symbols and Arrows + } elseif ($decimal < 11360) { + $return = '2c00_2c5f'; // Glagolitic + } elseif ($decimal < 11392) { + $return = '2c60_2c7f'; // Latin Extended-C + } elseif ($decimal < 11520) { + $return = '2c80_2cff'; // Coptic + } elseif ($decimal < 11568) { + $return = '2d00_2d2f'; // Georgian Supplement + } elseif ($decimal < 11648) { + $return = '2d30_2d7f'; // Tifinagh + } elseif ($decimal < 11776) { + $return = '2d80_2ddf'; // Ethiopic Extended + } elseif ($decimal < 11904) { + $return = '2e00_2e7f'; // Supplemental Punctuation + } elseif ($decimal < 12032) { + $return = '2e80_2eff'; // CJK Radicals Supplement + } elseif ($decimal < 12272) { + $return = '2f00_2fdf'; // Kangxi Radicals + } elseif ($decimal < 12288) { + $return = '2ff0_2fff'; // Ideographic Description Characters + } elseif ($decimal < 12352) { + $return = '3000_303f'; // CJK Symbols and Punctuation + } elseif ($decimal < 12448) { + $return = '3040_309f'; // Hiragana + } elseif ($decimal < 12544) { + $return = '30a0_30ff'; // Katakana + } elseif ($decimal < 12592) { + $return = '3100_312f'; // Bopomofo + } elseif ($decimal < 12688) { + $return = '3130_318f'; // Hangul Compatibility Jamo + } elseif ($decimal < 12704) { + $return = '3190_319f'; // Kanbun + } elseif ($decimal < 12736) { + $return = '31a0_31bf'; // Bopomofo Extended + } elseif ($decimal < 12784) { + $return = '31c0_31ef'; // CJK Strokes + } elseif ($decimal < 12800) { + $return = '31f0_31ff'; // Katakana Phonetic Extensions + } elseif ($decimal < 13056) { + $return = '3200_32ff'; // Enclosed CJK Letters and Months + } elseif ($decimal < 13312) { + $return = '3300_33ff'; // CJK Compatibility + } elseif ($decimal < 19904) { + $return = '3400_4dbf'; // CJK Unified Ideographs Extension A + } elseif ($decimal < 19968) { + $return = '4dc0_4dff'; // Yijing Hexagram Symbols + } elseif ($decimal < 40960) { + $return = '4e00_9fff'; // CJK Unified Ideographs + } elseif ($decimal < 42128) { + $return = 'a000_a48f'; // Yi Syllables + } elseif ($decimal < 42752) { + $return = 'a490_a4cf'; // Yi Radicals + } elseif ($decimal < 42784) { + $return = 'a700_a71f'; // Modifier Tone Letters + } elseif ($decimal < 43008) { + $return = 'a720_a7ff'; // Latin Extended-D + } elseif ($decimal < 43072) { + $return = 'a800_a82f'; // Syloti Nagri + } elseif ($decimal < 44032) { + $return = 'a840_a87f'; // Phags-pa + } elseif ($decimal < 55296) { + $return = 'ac00_d7af'; // Hangul Syllables + } elseif ($decimal < 56192) { + $return = 'd800_db7f'; // High Surrogates + } elseif ($decimal < 56320) { + $return = 'db80_dbff'; // High Private Use Surrogates + } elseif ($decimal < 57344) { + $return = 'dc00_dfff'; // Low Surrogates + } elseif ($decimal < 63744) { + $return = 'e000_f8ff'; // Private Use Area + } elseif ($decimal < 64256) { + $return = 'f900_faff'; // CJK Compatibility Ideographs + } elseif ($decimal < 64336) { + $return = 'fb00_fb4f'; // Alphabetic Presentation Forms + } elseif ($decimal < 65024) { + $return = 'fb50_fdff'; // Arabic Presentation Forms-A + } elseif ($decimal < 65040) { + $return = 'fe00_fe0f'; // Variation Selectors + } elseif ($decimal < 65056) { + $return = 'fe10_fe1f'; // Vertical Forms + } elseif ($decimal < 65072) { + $return = 'fe20_fe2f'; // Combining Half Marks + } elseif ($decimal < 65104) { + $return = 'fe30_fe4f'; // CJK Compatibility Forms + } elseif ($decimal < 65136) { + $return = 'fe50_fe6f'; // Small Form Variants + } elseif ($decimal < 65280) { + $return = 'fe70_feff'; // Arabic Presentation Forms-B + } elseif ($decimal < 65520) { + $return = 'ff00_ffef'; // Halfwidth and Fullwidth Forms + } elseif ($decimal < 65536) { + $return = 'fff0_ffff'; // Specials + } elseif ($decimal < 65664) { + $return = '10000_1007f'; // Linear B Syllabary + } elseif ($decimal < 65792) { + $return = '10080_100ff'; // Linear B Ideograms + } elseif ($decimal < 65856) { + $return = '10100_1013f'; // Aegean Numbers + } elseif ($decimal < 66304) { + $return = '10140_1018f'; // Ancient Greek Numbers + } elseif ($decimal < 66352) { + $return = '10300_1032f'; // Old Italic + } elseif ($decimal < 66432) { + $return = '10330_1034f'; // Gothic + } elseif ($decimal < 66464) { + $return = '10380_1039f'; // Ugaritic + } elseif ($decimal < 66560) { + $return = '103a0_103df'; // Old Persian + } elseif ($decimal < 66640) { + $return = '10400_1044f'; // Deseret + } elseif ($decimal < 66688) { + $return = '10450_1047f'; // Shavian + } elseif ($decimal < 67584) { + $return = '10480_104af'; // Osmanya + } elseif ($decimal < 67840) { + $return = '10800_1083f'; // Cypriot Syllabary + } elseif ($decimal < 68096) { + $return = '10900_1091f'; // Phoenician + } elseif ($decimal < 73728) { + $return = '10a00_10a5f'; // Kharoshthi + } elseif ($decimal < 74752) { + $return = '12000_123ff'; // Cuneiform + } elseif ($decimal < 118784) { + $return = '12400_1247f'; // Cuneiform Numbers and Punctuation + } elseif ($decimal < 119040) { + $return = '1d000_1d0ff'; // Byzantine Musical Symbols + } elseif ($decimal < 119296) { + $return = '1d100_1d1ff'; // Musical Symbols + } elseif ($decimal < 119552) { + $return = '1d200_1d24f'; // Ancient Greek Musical Notation + } elseif ($decimal < 119648) { + $return = '1d300_1d35f'; // Tai Xuan Jing Symbols + } elseif ($decimal < 119808) { + $return = '1d360_1d37f'; // Counting Rod Numerals + } elseif ($decimal < 131072) { + $return = '1d400_1d7ff'; // Mathematical Alphanumeric Symbols + } elseif ($decimal < 194560) { + $return = '20000_2a6df'; // CJK Unified Ideographs Extension B + } elseif ($decimal < 917504) { + $return = '2f800_2fa1f'; // CJK Compatibility Ideographs Supplement + } elseif ($decimal < 917760) { + $return = 'e0000_e007f'; // Tags + } elseif ($decimal < 983040) { + $return = 'e0100_e01ef'; // Variation Selectors Supplement + } elseif ($decimal < 1048576) { + $return = 'f0000_fffff'; // Supplementary Private Use Area-A + } elseif ($decimal > 1048575) { + $return = '100000_10ffff'; // Supplementary Private Use Area-B + } else { + $return = false; + } + $_this->__codeRange[$decimal] = $return; + return $return; + } +/** + * Find the related code folding values for $char + * + * @param integer $char decimal value of character + * @param string $type + * @return array + * @access private + */ + function __find($char, $type = 'lower'){ + $_this =& Multibyte::getInstance(); + $value = false; + $found = array(); + if(!isset($_this->__codeRange[$char])) { + $range = $_this->__codepoint($char); + if ($range === false) { + + } + Configure::load('unicode' . DS . 'casefolding' . DS . $range); + $_this->__caseFold[$range] = Configure::read($range); + Configure::delete($range); + } + $_this->__table = $_this->__codeRange[$char]; + $count = count($_this->__caseFold[$_this->__table]); + + for($i = 0; $i < $count; $i++) { + if ($type === 'lower' && $_this->__caseFold[$_this->__table][$i][$type][0] === $char) { + $found[] = $_this->__caseFold[$_this->__table][$i]; + } elseif ($type === 'upper' && $_this->__caseFold[$_this->__table][$i][$type] === $char) { + $found[] = $_this->__caseFold[$_this->__table][$i]; + } + } + return $found; + } +/** + * resets the utf8 map array + * + * @access private + */ + function __reset() { + $_this =& Multibyte::getInstance(); + $_this->__utf8Map = array(); + } +/** + * Check the $string for multibyte characters + * + * @access private + */ + function __checkMultibyte($string) { + $length = strlen($string); + + for ($i = 0; $i < $length; $i++ ) { + $value = ord(($string[$i])); + if ($value > 128) { + return true; + } + } + return false; + } +} +?> \ No newline at end of file diff --git a/cake/tests/cases/libs/multibyte.test.php b/cake/tests/cases/libs/multibyte.test.php new file mode 100644 index 000000000..979b156bd --- /dev/null +++ b/cake/tests/cases/libs/multibyte.test.php @@ -0,0 +1,8507 @@ + + * Copyright 2005-2008, Cake Software Foundation, Inc. + * 1785 E. Sahara Avenue, Suite 490-204 + * Las Vegas, Nevada 89104 + * + * Licensed under The Open Group Test Suite License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. + * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests + * @package cake.tests + * @subpackage cake.tests.cases.libs + * @since CakePHP(tm) v 1.2.0.6833 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License + */ +App::import('Core', 'Multibyte'); +/** + * Short description for class. + * + * @package cake.tests + * @subpackage cake.tests.cases.libs + */ +class MultibyteTest extends UnitTestCase { + + function testUtf8() { + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $result = Multibyte::utf8($string); + $expected = array(33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, + 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, + 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126); + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $result = Multibyte::utf8($string); + $expected = array(161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, + 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200); + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $result = Multibyte::utf8($string); + $expected = array(201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, + 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, + 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300); + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $result = Multibyte::utf8($string); + $expected = array(301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, + 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, + 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, + 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400); + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $result = Multibyte::utf8($string); + $expected = array(401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, + 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, + 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, + 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, + 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500); + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $result = Multibyte::utf8($string); + $expected = array(601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, + 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, + 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, + 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, + 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700); + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $result = Multibyte::utf8($string); + $expected = array(1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, + 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051); + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $result = Multibyte::utf8($string); + $expected = array(1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, + 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, + 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100); + $this->assertEqual($result, $expected); + + $string = 'չպջռսվտ'; + $result = Multibyte::utf8($string); + $expected = array(1401, 1402, 1403, 1404, 1405, 1406, 1407); + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $result = Multibyte::utf8($string); + $expected = array(1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615); + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $result = Multibyte::utf8($string); + $expected = array(10032, 10033, 10034, 10035, 10036, 10037, 10038, 10039, 10040, 10041, 10042, 10043, 10044, + 10045, 10046, 10047, 10048, 10049, 10050, 10051, 10052, 10053, 10054, 10055, 10056, 10057, + 10058, 10059, 10060, 10061, 10062, 10063, 10064, 10065, 10066, 10067, 10068, 10069, 10070, + 10071, 10072, 10073, 10074, 10075, 10076, 10077, 10078); + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $result = Multibyte::utf8($string); + $expected = array(11904, 11905, 11906, 11907, 11908, 11909, 11910, 11911, 11912, 11913, 11914, 11915, 11916, 11917, 11918, 11919, + 11920, 11921, 11922, 11923, 11924, 11925, 11926, 11927, 11928, 11929, 11931, 11932, 11933, 11934, 11935, 11936, + 11937, 11938, 11939, 11940, 11941, 11942, 11943, 11944, 11945, 11946, 11947, 11948, 11949, 11950, 11951, 11952, + 11953, 11954, 11955, 11956, 11957, 11958, 11959, 11960, 11961, 11962, 11963, 11964, 11965, 11966, 11967, 11968, + 11969, 11970, 11971, 11972, 11973, 11974, 11975, 11976, 11977, 11978, 11979, 11980, 11981, 11982, 11983, 11984, + 11985, 11986, 11987, 11988, 11989, 11990, 11991, 11992, 11993, 11994, 11995, 11996, 11997, 11998, 11999, 12000); + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $result = Multibyte::utf8($string); + $expected = array(12101, 12102, 12103, 12104, 12105, 12106, 12107, 12108, 12109, 12110, 12111, 12112, 12113, 12114, 12115, 12116, + 12117, 12118, 12119, 12120, 12121, 12122, 12123, 12124, 12125, 12126, 12127, 12128, 12129, 12130, 12131, 12132, + 12133, 12134, 12135, 12136, 12137, 12138, 12139, 12140, 12141, 12142, 12143, 12144, 12145, 12146, 12147, 12148, + 12149, 12150, 12151, 12152, 12153, 12154, 12155, 12156, 12157, 12158, 12159); + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $result = Multibyte::utf8($string); + $expected = array(45601, 45602, 45603, 45604, 45605, 45606, 45607, 45608, 45609, 45610, 45611, 45612, 45613, 45614, 45615, 45616, + 45617, 45618, 45619, 45620, 45621, 45622, 45623, 45624, 45625, 45626, 45627, 45628, 45629, 45630, 45631, 45632, + 45633, 45634, 45635, 45636, 45637, 45638, 45639, 45640, 45641, 45642, 45643, 45644, 45645, 45646, 45647, 45648, + 45649, 45650, 45651, 45652, 45653, 45654, 45655, 45656, 45657, 45658, 45659, 45660, 45661, 45662, 45663, 45664, + 45665, 45666, 45667, 45668, 45669, 45670, 45671, 45672, 45673, 45674, 45675, 45676, 45677, 45678, 45679, 45680, + 45681, 45682, 45683, 45684, 45685, 45686, 45687, 45688, 45689, 45690, 45691, 45692, 45693, 45694, 45695, 45696, + 45697, 45698, 45699, 45700); + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $result = Multibyte::utf8($string); + $expected = array(65136, 65137, 65138, 65139, 65140, 65141, 65142, 65143, 65144, 65145, 65146, 65147, 65148, 65149, 65150, 65151, + 65152, 65153, 65154, 65155, 65156, 65157, 65158, 65159, 65160, 65161, 65162, 65163, 65164, 65165, 65166, 65167, + 65168, 65169, 65170, 65171, 65172, 65173, 65174, 65175, 65176, 65177, 65178, 65179, 65180, 65181, 65182, 65183, + 65184, 65185, 65186, 65187, 65188, 65189, 65190, 65191, 65192, 65193, 65194, 65195, 65196, 65197, 65198, 65199, + 65200); + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $result = Multibyte::utf8($string); + $expected = array(65201, 65202, 65203, 65204, 65205, 65206, 65207, 65208, 65209, 65210, 65211, 65212, 65213, 65214, 65215, 65216, + 65217, 65218, 65219, 65220, 65221, 65222, 65223, 65224, 65225, 65226, 65227, 65228, 65229, 65230, 65231, 65232, + 65233, 65234, 65235, 65236, 65237, 65238, 65239, 65240, 65241, 65242, 65243, 65244, 65245, 65246, 65247, 65248, + 65249, 65250, 65251, 65252, 65253, 65254, 65255, 65256, 65257, 65258, 65259, 65260, 65261, 65262, 65263, 65264, + 65265, 65266, 65267, 65268, 65269, 65270, 65271, 65272, 65273, 65274, 65275, 65276); + $this->assertEqual($result, $expected); + + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $result = Multibyte::utf8($string); + $expected = array(65345, 65346, 65347, 65348, 65349, 65350, 65351, 65352, 65353, 65354, 65355, 65356, 65357, 65358, 65359, 65360, + 65361, 65362, 65363, 65364, 65365, 65366, 65367, 65368, 65369, 65370); + $this->assertEqual($result, $expected); + + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $result = Multibyte::utf8($string); + $expected = array(65377, 65378, 65379, 65380, 65381, 65382, 65383, 65384, 65385, 65386, 65387, 65388, 65389, 65390, 65391, 65392, + 65393, 65394, 65395, 65396, 65397, 65398, 65399, 65400); + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $result = Multibyte::utf8($string); + $expected = array(65401, 65402, 65403, 65404, 65405, 65406, 65407, 65408, 65409, 65410, 65411, 65412, 65413, 65414, 65415, 65416, + 65417, 65418, 65419, 65420, 65421, 65422, 65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430, 65431, 65432, + 65433, 65434, 65435, 65436, 65437, 65438); + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $result = Multibyte::utf8($string); + $expected = array(292, 275, 314, 316, 335, 44, 32, 372, 337, 345, 316, 271, 33); + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $result = Multibyte::utf8($string); + $expected = array(72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33); + $this->assertEqual($result, $expected); + + $string = '¨'; + $result = Multibyte::utf8($string); + $expected = array(168); + $this->assertEqual($result, $expected); + + $string = '¿'; + $result = Multibyte::utf8($string); + $expected = array(191); + $this->assertEqual($result, $expected); + + $string = 'čini'; + $result = Multibyte::utf8($string); + $expected = array(269, 105, 110, 105); + $this->assertEqual($result, $expected); + + $string = 'moći'; + $result = Multibyte::utf8($string); + $expected = array(109, 111, 263, 105); + $this->assertEqual($result, $expected); + + $string = 'državni'; + $result = Multibyte::utf8($string); + $expected = array(100, 114, 382, 97, 118, 110, 105); + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $result = Multibyte::utf8($string); + $expected = array(25226, 30334, 24230, 35774, 20026, 39318, 39029); + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $result = Multibyte::utf8($string); + $expected = array(19968, 20108, 19977, 21608, 27704, 40845); + $this->assertEqual($result, $expected); + } + + function testAscii() { + $utf8 = array(33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, + 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, + 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126); + $result = Multibyte::ascii($utf8); + + $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $this->assertEqual($result, $expected); + + $utf8 = array(161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, + 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200); + $result = Multibyte::ascii($utf8); + + $expected = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $this->assertEqual($result, $expected); + + $utf8 = array(201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, + 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, + 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300); + $result = Multibyte::ascii($utf8); + $expected = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $this->assertEqual($result, $expected); + + $utf8 = array(301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, + 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, + 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, + 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, + 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400); + $expected = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, + 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, + 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, + 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, + 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500); + $expected = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, + 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, + 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, + 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, + 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700); + $expected = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, + 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051); + $expected = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, + 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, + 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100); + $expected = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(1401, 1402, 1403, 1404, 1405, 1406, 1407); + $expected = 'չպջռսվտ'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615); + $expected = 'فقكلمنهوىيًٌٍَُ'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(10032, 10033, 10034, 10035, 10036, 10037, 10038, 10039, 10040, 10041, 10042, 10043, 10044, + 10045, 10046, 10047, 10048, 10049, 10050, 10051, 10052, 10053, 10054, 10055, 10056, 10057, + 10058, 10059, 10060, 10061, 10062, 10063, 10064, 10065, 10066, 10067, 10068, 10069, 10070, + 10071, 10072, 10073, 10074, 10075, 10076, 10077, 10078); + $expected = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(11904, 11905, 11906, 11907, 11908, 11909, 11910, 11911, 11912, 11913, 11914, 11915, 11916, 11917, 11918, 11919, + 11920, 11921, 11922, 11923, 11924, 11925, 11926, 11927, 11928, 11929, 11931, 11932, 11933, 11934, 11935, 11936, + 11937, 11938, 11939, 11940, 11941, 11942, 11943, 11944, 11945, 11946, 11947, 11948, 11949, 11950, 11951, 11952, + 11953, 11954, 11955, 11956, 11957, 11958, 11959, 11960, 11961, 11962, 11963, 11964, 11965, 11966, 11967, 11968, + 11969, 11970, 11971, 11972, 11973, 11974, 11975, 11976, 11977, 11978, 11979, 11980, 11981, 11982, 11983, 11984, + 11985, 11986, 11987, 11988, 11989, 11990, 11991, 11992, 11993, 11994, 11995, 11996, 11997, 11998, 11999, 12000); + $expected = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(12101, 12102, 12103, 12104, 12105, 12106, 12107, 12108, 12109, 12110, 12111, 12112, 12113, 12114, 12115, 12116, + 12117, 12118, 12119, 12120, 12121, 12122, 12123, 12124, 12125, 12126, 12127, 12128, 12129, 12130, 12131, 12132, + 12133, 12134, 12135, 12136, 12137, 12138, 12139, 12140, 12141, 12142, 12143, 12144, 12145, 12146, 12147, 12148, + 12149, 12150, 12151, 12152, 12153, 12154, 12155, 12156, 12157, 12158, 12159); + $expected = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(45601, 45602, 45603, 45604, 45605, 45606, 45607, 45608, 45609, 45610, 45611, 45612, 45613, 45614, 45615, 45616, + 45617, 45618, 45619, 45620, 45621, 45622, 45623, 45624, 45625, 45626, 45627, 45628, 45629, 45630, 45631, 45632, + 45633, 45634, 45635, 45636, 45637, 45638, 45639, 45640, 45641, 45642, 45643, 45644, 45645, 45646, 45647, 45648, + 45649, 45650, 45651, 45652, 45653, 45654, 45655, 45656, 45657, 45658, 45659, 45660, 45661, 45662, 45663, 45664, + 45665, 45666, 45667, 45668, 45669, 45670, 45671, 45672, 45673, 45674, 45675, 45676, 45677, 45678, 45679, 45680, + 45681, 45682, 45683, 45684, 45685, 45686, 45687, 45688, 45689, 45690, 45691, 45692, 45693, 45694, 45695, 45696, + 45697, 45698, 45699, 45700); + $expected = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(65136, 65137, 65138, 65139, 65140, 65141, 65142, 65143, 65144, 65145, 65146, 65147, 65148, 65149, 65150, 65151, + 65152, 65153, 65154, 65155, 65156, 65157, 65158, 65159, 65160, 65161, 65162, 65163, 65164, 65165, 65166, 65167, + 65168, 65169, 65170, 65171, 65172, 65173, 65174, 65175, 65176, 65177, 65178, 65179, 65180, 65181, 65182, 65183, + 65184, 65185, 65186, 65187, 65188, 65189, 65190, 65191, 65192, 65193, 65194, 65195, 65196, 65197, 65198, 65199, + 65200); + $expected = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(65201, 65202, 65203, 65204, 65205, 65206, 65207, 65208, 65209, 65210, 65211, 65212, 65213, 65214, 65215, 65216, + 65217, 65218, 65219, 65220, 65221, 65222, 65223, 65224, 65225, 65226, 65227, 65228, 65229, 65230, 65231, 65232, + 65233, 65234, 65235, 65236, 65237, 65238, 65239, 65240, 65241, 65242, 65243, 65244, 65245, 65246, 65247, 65248, + 65249, 65250, 65251, 65252, 65253, 65254, 65255, 65256, 65257, 65258, 65259, 65260, 65261, 65262, 65263, 65264, + 65265, 65266, 65267, 65268, 65269, 65270, 65271, 65272, 65273, 65274, 65275, 65276); + $expected = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(65345, 65346, 65347, 65348, 65349, 65350, 65351, 65352, 65353, 65354, 65355, 65356, 65357, 65358, 65359, 65360, + 65361, 65362, 65363, 65364, 65365, 65366, 65367, 65368, 65369, 65370); + $expected = 'abcdefghijklmnopqrstuvwxyz'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(65377, 65378, 65379, 65380, 65381, 65382, 65383, 65384, 65385, 65386, 65387, 65388, 65389, 65390, 65391, 65392, + 65393, 65394, 65395, 65396, 65397, 65398, 65399, 65400); + $expected = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(65401, 65402, 65403, 65404, 65405, 65406, 65407, 65408, 65409, 65410, 65411, 65412, 65413, 65414, 65415, 65416, + 65417, 65418, 65419, 65420, 65421, 65422, 65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430, 65431, 65432, + 65433, 65434, 65435, 65436, 65437, 65438); + $expected = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(292, 275, 314, 316, 335, 44, 32, 372, 337, 345, 316, 271, 33); + $expected = 'Ĥēĺļŏ, Ŵőřļď!'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33); + $expected = 'Hello, World!'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(168); + $expected = '¨'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(191); + $expected = '¿'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(269, 105, 110, 105); + $expected = 'čini'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(109, 111, 263, 105); + $expected = 'moći'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(100, 114, 382, 97, 118, 110, 105); + $expected = 'državni'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(25226, 30334, 24230, 35774, 20026, 39318, 39029); + $expected = '把百度设为首页'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + + $utf8 = array(19968, 20108, 19977, 21608, 27704, 40845); + $expected = '一二三周永龍'; + $result = Multibyte::ascii($utf8); + $this->assertEqual($result, $expected); + } + + function testUsingMbStripos() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'f'; + $result = mb_stripos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ABCDEFGHIJKLMNOPQFRSTUVWXYZ0123456789'; + $find = 'f'; + $result = mb_stripos($string, $find, 6); + $expected = 17; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'å'; + $result = mb_stripos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÅÙÚÛÜÝÞ'; + $find = 'å'; + $result = mb_stripos($string, $find, 6); + $expected = 24; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'ċ'; + $result = mb_stripos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁĊŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'ċ'; + $result = mb_stripos($string, $find, 6); + $expected = 32; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'f'; + $result = mb_stripos($string, $find); + $expected = 37; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'Μ'; + $result = mb_stripos($string, $find); + $expected = 20; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'É'; + $result = mb_stripos($string, $find, 6); + $expected = 32; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = mb_stripos($string, $find); + $expected = 24; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = mb_stripos($string, $find); + $expected = 39; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = mb_stripos($string, $find, 40); + $expected = 40; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'Ʀ'; + $result = mb_stripos($string, $find); + $expected = 39; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'ї'; + $result = mb_stripos($string, $find); + $expected = 7; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = mb_stripos($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = mb_stripos($string, $find, 5); + $expected = 36; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = mb_stripos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = mb_stripos($string, $find); + $expected = 15; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = mb_stripos($string, $find); + $expected = 16; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = mb_stripos($string, $find); + $expected = 31; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = mb_stripos($string, $find); + $expected = 26; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = mb_stripos($string, $find); + $expected = 46; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = mb_stripos($string, $find); + $expected = 45; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = mb_stripos($string, $find); + $expected = 10; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'K'; + $result = mb_stripos($string, $find); + $expected = 10; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = mb_stripos($string, $find); + $expected = 16; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = mb_stripos($string, $find); + $expected = 17; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = mb_stripos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'Ő'; + $result = mb_stripos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'O'; + $result = mb_stripos($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = mb_stripos($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = mb_stripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'N'; + $result = mb_stripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = mb_stripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'Ć'; + $result = mb_stripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = mb_stripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'Ž'; + $result = mb_stripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = mb_stripos($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = mb_stripos($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'DŽ'; + $result = mb_stripos($string, $find); + $expected = false; + $this->assertEqual($result, $expected); + } + + function testMultibyteStripos() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'f'; + $result = Multibyte::stripos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ABCDEFGHIJKLMNOPQFRSTUVWXYZ0123456789'; + $find = 'f'; + $result = Multibyte::stripos($string, $find, 6); + $expected = 17; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'å'; + $result = Multibyte::stripos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÅÙÚÛÜÝÞ'; + $find = 'å'; + $result = Multibyte::stripos($string, $find, 6); + $expected = 24; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'ċ'; + $result = Multibyte::stripos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁĊŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'ċ'; + $result = Multibyte::stripos($string, $find, 6); + $expected = 32; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'f'; + $result = Multibyte::stripos($string, $find); + $expected = 37; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'Μ'; + $result = Multibyte::stripos($string, $find); + $expected = 20; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'É'; + $result = Multibyte::stripos($string, $find, 6); + $expected = 32; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = Multibyte::stripos($string, $find); + $expected = 24; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = Multibyte::stripos($string, $find); + $expected = 39; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = Multibyte::stripos($string, $find, 40); + $expected = 40; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'Ʀ'; + $result = Multibyte::stripos($string, $find); + $expected = 39; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'ї'; + $result = Multibyte::stripos($string, $find); + $expected = 7; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = Multibyte::stripos($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = Multibyte::stripos($string, $find, 5); + $expected = 36; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = Multibyte::stripos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = Multibyte::stripos($string, $find); + $expected = 15; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = Multibyte::stripos($string, $find); + $expected = 16; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = Multibyte::stripos($string, $find); + $expected = 31; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = Multibyte::stripos($string, $find); + $expected = 26; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = Multibyte::stripos($string, $find); + $expected = 46; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = Multibyte::stripos($string, $find); + $expected = 45; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = Multibyte::stripos($string, $find); + $expected = 10; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'K'; + $result = Multibyte::stripos($string, $find); + $expected = 10; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = Multibyte::stripos($string, $find); + $expected = 16; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = Multibyte::stripos($string, $find); + $expected = 17; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = Multibyte::stripos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'Ő'; + $result = Multibyte::stripos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'O'; + $result = Multibyte::stripos($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = Multibyte::stripos($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = Multibyte::stripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'N'; + $result = Multibyte::stripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = Multibyte::stripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'Ć'; + $result = Multibyte::stripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = Multibyte::stripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'Ž'; + $result = Multibyte::stripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = Multibyte::stripos($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = Multibyte::stripos($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'DŽ'; + $result = Multibyte::stripos($string, $find); + $expected = false; + $this->assertEqual($result, $expected); + } + + function testUsingMbStristr() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'f'; + $result = mb_stristr($string, $find); + $expected = 'FGHIJKLMNOPQRSTUVWXYZ0123456789'; + $this->assertEqual($result, $expected); + + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'f'; + $result = mb_stristr($string, $find, true); + $expected = 'ABCDE'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'å'; + $result = mb_stristr($string, $find); + $expected = 'ÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'å'; + $result = mb_stristr($string, $find, true); + $expected = 'ÀÁÂÃÄ'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'ċ'; + $result = mb_stristr($string, $find); + $expected = 'ĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'ċ'; + $result = mb_stristr($string, $find, true); + $expected = 'ĀĂĄĆĈ'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'f'; + $result = mb_stristr($string, $find); + $expected = 'FGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'f'; + $result = mb_stristr($string, $find, true); + $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDE'; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'Μ'; + $result = mb_stristr($string, $find); + $expected = 'µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'Μ'; + $result = mb_stristr($string, $find, true); + $expected = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´'; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'þ'; + $result = mb_stristr($string, $find); + $expected = 'Þßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'þ'; + $result = mb_stristr($string, $find, true); + $expected = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝ'; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = mb_stristr($string, $find); + $expected = 'ŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = mb_stristr($string, $find, true); + $expected = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃń'; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = mb_stristr($string, $find); + $expected = 'ƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $this->assertEqual($result, $expected); + + $find = 'Ƹ'; + $result = mb_stristr($string, $find, true); + $expected = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷ'; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'Ʀ'; + $result = mb_stristr($string, $find); + $expected = 'ʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'Ʀ'; + $result = mb_stristr($string, $find, true); + $expected = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿ'; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'ї'; + $result = mb_stristr($string, $find); + $expected = 'ЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'ї'; + $result = mb_stristr($string, $find, true); + $expected = 'ЀЁЂЃЄЅІ'; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = mb_stristr($string, $find); + $expected = 'РСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = mb_stristr($string, $find, true); + $expected = 'МНОП'; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = mb_stristr($string, $find); + $expected = 'نهوىيًٌٍَُ'; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = mb_stristr($string, $find, true); + $expected = 'فقكلم'; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = mb_stristr($string, $find); + $expected = '✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = mb_stristr($string, $find, true); + $expected = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾'; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = mb_stristr($string, $find); + $expected = '⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = mb_stristr($string, $find, true); + $expected = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏'; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = mb_stristr($string, $find); + $expected = '⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = mb_stristr($string, $find, true); + $expected = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣'; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = mb_stristr($string, $find); + $expected = '눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = mb_stristr($string, $find, true); + $expected = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺'; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = mb_stristr($string, $find); + $expected = 'ﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = mb_stristr($string, $find, true); + $expected = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝ'; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = mb_stristr($string, $find); + $expected = 'ﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = mb_stristr($string, $find, true); + $expected = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝ'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'K'; + $result = mb_stristr($string, $find); + $expected = 'klmnopqrstuvwxyz'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'K'; + $result = mb_stristr($string, $find, true); + $expected = 'abcdefghij'; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = mb_stristr($string, $find); + $expected = 'アイウエオカキク'; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = mb_stristr($string, $find, true); + $expected = '。「」、・ヲァィゥェォャュョッー'; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = mb_stristr($string, $find); + $expected = 'ハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = mb_stristr($string, $find, true); + $expected = 'ケコサシスセソタチツテトナニヌネノ'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'Ő'; + $result = mb_stristr($string, $find); + $expected = 'őřļď!'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'Ő'; + $result = mb_stristr($string, $find, true); + $expected = 'Ĥēĺļŏ, Ŵ'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ĺļ'; + $result = mb_stristr($string, $find, true); + $expected = 'Ĥē'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'O'; + $result = mb_stristr($string, $find); + $expected = 'o, World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'O'; + $result = mb_stristr($string, $find, true); + $expected = 'Hell'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'Wo'; + $result = mb_stristr($string, $find); + $expected = 'World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'Wo'; + $result = mb_stristr($string, $find, true); + $expected = 'Hello, '; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'll'; + $result = mb_stristr($string, $find); + $expected = 'llo, World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'll'; + $result = mb_stristr($string, $find, true); + $expected = 'He'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'rld'; + $result = mb_stristr($string, $find); + $expected = 'rld!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'rld'; + $result = mb_stristr($string, $find, true); + $expected = 'Hello, Wo'; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'N'; + $result = mb_stristr($string, $find); + $expected = 'ni'; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'N'; + $result = mb_stristr($string, $find, true); + $expected = 'či'; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'Ć'; + $result = mb_stristr($string, $find); + $expected = 'ći'; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'Ć'; + $result = mb_stristr($string, $find, true); + $expected = 'mo'; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'Ž'; + $result = mb_stristr($string, $find); + $expected = 'žavni'; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'Ž'; + $result = mb_stristr($string, $find, true); + $expected = 'dr'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = mb_stristr($string, $find); + $expected = '设为首页'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = mb_stristr($string, $find, true); + $expected = '把百度'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = mb_stristr($string, $find); + $expected = '周永龍'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = mb_stristr($string, $find, true); + $expected = '一二三'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '二周'; + $result = mb_stristr($string, $find); + $expected = false; + $this->assertEqual($result, $expected); + } + + function testMultibyteStristr() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'f'; + $result = Multibyte::stristr($string, $find); + $expected = 'FGHIJKLMNOPQRSTUVWXYZ0123456789'; + $this->assertEqual($result, $expected); + + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'f'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'ABCDE'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'å'; + $result = Multibyte::stristr($string, $find); + $expected = 'ÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'å'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'ÀÁÂÃÄ'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'ċ'; + $result = Multibyte::stristr($string, $find); + $expected = 'ĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'ċ'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'ĀĂĄĆĈ'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'f'; + $result = Multibyte::stristr($string, $find); + $expected = 'FGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'f'; + $result = Multibyte::stristr($string, $find, true); + $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDE'; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'Μ'; + $result = Multibyte::stristr($string, $find); + $expected = 'µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'Μ'; + $result = Multibyte::stristr($string, $find, true); + $expected = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´'; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'þ'; + $result = Multibyte::stristr($string, $find); + $expected = 'Þßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'þ'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝ'; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = Multibyte::stristr($string, $find); + $expected = 'ŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃń'; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = Multibyte::stristr($string, $find); + $expected = 'ƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $this->assertEqual($result, $expected); + + $find = 'Ƹ'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷ'; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'Ʀ'; + $result = Multibyte::stristr($string, $find); + $expected = 'ʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'Ʀ'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿ'; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'ї'; + $result = Multibyte::stristr($string, $find); + $expected = 'ЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'ї'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'ЀЁЂЃЄЅІ'; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = Multibyte::stristr($string, $find); + $expected = 'РСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'МНОП'; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = Multibyte::stristr($string, $find); + $expected = 'نهوىيًٌٍَُ'; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'فقكلم'; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = Multibyte::stristr($string, $find); + $expected = '✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = Multibyte::stristr($string, $find, true); + $expected = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾'; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = Multibyte::stristr($string, $find); + $expected = '⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = Multibyte::stristr($string, $find, true); + $expected = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏'; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = Multibyte::stristr($string, $find); + $expected = '⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = Multibyte::stristr($string, $find, true); + $expected = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣'; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = Multibyte::stristr($string, $find); + $expected = '눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = Multibyte::stristr($string, $find, true); + $expected = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺'; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = Multibyte::stristr($string, $find); + $expected = 'ﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝ'; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = Multibyte::stristr($string, $find); + $expected = 'ﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝ'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'K'; + $result = Multibyte::stristr($string, $find); + $expected = 'klmnopqrstuvwxyz'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'K'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'abcdefghij'; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = Multibyte::stristr($string, $find); + $expected = 'アイウエオカキク'; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = Multibyte::stristr($string, $find, true); + $expected = '。「」、・ヲァィゥェォャュョッー'; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = Multibyte::stristr($string, $find); + $expected = 'ハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'ケコサシスセソタチツテトナニヌネノ'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'Ő'; + $result = Multibyte::stristr($string, $find); + $expected = 'őřļď!'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'Ő'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'Ĥēĺļŏ, Ŵ'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ĺļ'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'Ĥē'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'O'; + $result = Multibyte::stristr($string, $find); + $expected = 'o, World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'O'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'Hell'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'Wo'; + $result = Multibyte::stristr($string, $find); + $expected = 'World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'Wo'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'Hello, '; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'll'; + $result = Multibyte::stristr($string, $find); + $expected = 'llo, World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'll'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'He'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'rld'; + $result = Multibyte::stristr($string, $find); + $expected = 'rld!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'rld'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'Hello, Wo'; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'N'; + $result = Multibyte::stristr($string, $find); + $expected = 'ni'; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'N'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'či'; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'Ć'; + $result = Multibyte::stristr($string, $find); + $expected = 'ći'; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'Ć'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'mo'; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'Ž'; + $result = Multibyte::stristr($string, $find); + $expected = 'žavni'; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'Ž'; + $result = Multibyte::stristr($string, $find, true); + $expected = 'dr'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = Multibyte::stristr($string, $find); + $expected = '设为首页'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = Multibyte::stristr($string, $find, true); + $expected = '把百度'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = Multibyte::stristr($string, $find); + $expected = '周永龍'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = Multibyte::stristr($string, $find, true); + $expected = '一二三'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '二周'; + $result = Multibyte::stristr($string, $find); + $expected = false; + $this->assertEqual($result, $expected); + } + + function testUsingMbStrlen() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $result = mb_strlen($string); + $expected = 36; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $result = mb_strlen($string); + $expected = 30; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $result = mb_strlen($string); + $expected = 61; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $result = mb_strlen($string); + $expected = 94; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $result = mb_strlen($string); + $expected = 40; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $result = mb_strlen($string); + $expected = 100; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $result = mb_strlen($string); + $expected = 100; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $result = mb_strlen($string); + $expected = 100; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $result = mb_strlen($string); + $expected = 100; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $result = mb_strlen($string); + $expected = 28; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $result = mb_strlen($string); + $expected = 49; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $result = mb_strlen($string); + $expected = 15; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $result = mb_strlen($string); + $expected = 47; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $result = mb_strlen($string); + $expected = 96; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $result = mb_strlen($string); + $expected = 59; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $result = mb_strlen($string); + $expected = 100; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $result = mb_strlen($string); + $expected = 65; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $result = mb_strlen($string); + $expected = 76; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $result = mb_strlen($string); + $expected = 26; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $result = mb_strlen($string); + $expected = 24; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $result = mb_strlen($string); + $expected = 38; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $result = mb_strlen($string); + $expected = 13; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $result = mb_strlen($string); + $expected = 13; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $result = mb_strlen($string); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $result = mb_strlen($string); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $result = mb_strlen($string); + $expected = 7; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $result = mb_strlen($string); + $expected = 7; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $result = mb_strlen($string); + $expected = 6; + $this->assertEqual($result, $expected); + } + + function testMultibyteStrlen() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $result = Multibyte::strlen($string); + $expected = 36; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $result = Multibyte::strlen($string); + $expected = 30; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $result = Multibyte::strlen($string); + $expected = 61; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $result = Multibyte::strlen($string); + $expected = 94; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $result = Multibyte::strlen($string); + $expected = 40; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $result = Multibyte::strlen($string); + $expected = 100; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $result = Multibyte::strlen($string); + $expected = 100; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $result = Multibyte::strlen($string); + $expected = 100; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $result = Multibyte::strlen($string); + $expected = 100; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $result = Multibyte::strlen($string); + $expected = 28; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $result = Multibyte::strlen($string); + $expected = 49; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $result = Multibyte::strlen($string); + $expected = 15; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $result = Multibyte::strlen($string); + $expected = 47; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $result = Multibyte::strlen($string); + $expected = 96; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $result = Multibyte::strlen($string); + $expected = 59; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $result = Multibyte::strlen($string); + $expected = 100; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $result = Multibyte::strlen($string); + $expected = 65; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $result = Multibyte::strlen($string); + $expected = 76; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $result = Multibyte::strlen($string); + $expected = 26; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $result = Multibyte::strlen($string); + $expected = 24; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $result = Multibyte::strlen($string); + $expected = 38; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $result = Multibyte::strlen($string); + $expected = 13; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $result = Multibyte::strlen($string); + $expected = 13; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $result = Multibyte::strlen($string); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $result = Multibyte::strlen($string); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $result = Multibyte::strlen($string); + $expected = 7; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $result = Multibyte::strlen($string); + $expected = 7; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $result = Multibyte::strlen($string); + $expected = 6; + $this->assertEqual($result, $expected); + } + + function testUsingMbStrpos() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = mb_strpos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ABCDEFGHIJKLMNOPQFRSTUVWXYZ0123456789'; + $find = 'F'; + $result = mb_strpos($string, $find, 6); + $expected = 17; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'Å'; + $result = mb_strpos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÅÙÚÛÜÝÞ'; + $find = 'Å'; + $result = mb_strpos($string, $find, 6); + $expected = 24; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = mb_strpos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁĊŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = mb_strpos($string, $find, 6); + $expected = 32; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'F'; + $result = mb_strpos($string, $find); + $expected = 37; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'µ'; + $result = mb_strpos($string, $find); + $expected = 20; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'é'; + $result = mb_strpos($string, $find); + $expected = 32; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = mb_strpos($string, $find); + $expected = 24; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = mb_strpos($string, $find); + $expected = 39; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'ƹ'; + $result = mb_strpos($string, $find); + $expected = 40; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'ʀ'; + $result = mb_strpos($string, $find); + $expected = 39; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = mb_strpos($string, $find); + $expected = 7; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = mb_strpos($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'р'; + $result = mb_strpos($string, $find, 5); + $expected = 36; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = mb_strpos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = mb_strpos($string, $find); + $expected = 15; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = mb_strpos($string, $find); + $expected = 16; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = mb_strpos($string, $find); + $expected = 31; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = mb_strpos($string, $find); + $expected = 26; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = mb_strpos($string, $find); + $expected = 46; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = mb_strpos($string, $find); + $expected = 45; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = mb_strpos($string, $find); + $expected = 10; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = mb_strpos($string, $find); + $expected = 10; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = mb_strpos($string, $find); + $expected = 16; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = mb_strpos($string, $find); + $expected = 17; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = mb_strpos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = mb_strpos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'őř'; + $result = mb_strpos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = mb_strpos($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = mb_strpos($string, $find, 5); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = mb_strpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = mb_strpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = mb_strpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = mb_strpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = mb_strpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = mb_strpos($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = mb_strpos($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '一周'; + $result = mb_strpos($string, $find); + $expected = false; + $this->assertEqual($result, $expected); + } + + function testMultibyteStrpos() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = Multibyte::strpos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ABCDEFGHIJKLMNOPQFRSTUVWXYZ0123456789'; + $find = 'F'; + $result = Multibyte::strpos($string, $find, 6); + $expected = 17; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'Å'; + $result = Multibyte::strpos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÅÙÚÛÜÝÞ'; + $find = 'Å'; + $result = Multibyte::strpos($string, $find, 6); + $expected = 24; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = Multibyte::strpos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁĊŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = Multibyte::strpos($string, $find, 6); + $expected = 32; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'F'; + $result = Multibyte::strpos($string, $find); + $expected = 37; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'µ'; + $result = Multibyte::strpos($string, $find); + $expected = 20; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'é'; + $result = Multibyte::strpos($string, $find); + $expected = 32; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = Multibyte::strpos($string, $find); + $expected = 24; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = Multibyte::strpos($string, $find); + $expected = 39; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'ƹ'; + $result = Multibyte::strpos($string, $find); + $expected = 40; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'ʀ'; + $result = Multibyte::strpos($string, $find); + $expected = 39; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = Multibyte::strpos($string, $find); + $expected = 7; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = Multibyte::strpos($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'р'; + $result = Multibyte::strpos($string, $find, 5); + $expected = 36; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = Multibyte::strpos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = Multibyte::strpos($string, $find); + $expected = 15; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = Multibyte::strpos($string, $find); + $expected = 16; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = Multibyte::strpos($string, $find); + $expected = 31; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = Multibyte::strpos($string, $find); + $expected = 26; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = Multibyte::strpos($string, $find); + $expected = 46; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = Multibyte::strpos($string, $find); + $expected = 45; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = Multibyte::strpos($string, $find); + $expected = 10; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = Multibyte::strpos($string, $find); + $expected = 10; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = Multibyte::strpos($string, $find); + $expected = 16; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = Multibyte::strpos($string, $find); + $expected = 17; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = Multibyte::strpos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = Multibyte::strpos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'őř'; + $result = Multibyte::strpos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = Multibyte::strpos($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = Multibyte::strpos($string, $find, 5); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = Multibyte::strpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = Multibyte::strpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = Multibyte::strpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = Multibyte::strpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = Multibyte::strpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = Multibyte::strpos($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = Multibyte::strpos($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '一周'; + $result = Multibyte::strpos($string, $find); + $expected = false; + $this->assertEqual($result, $expected); + } + + function testUsingMbStrrchr() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = mb_strrchr($string, $find); + $expected = 'FGHIJKLMNOPQRSTUVWXYZ0123456789'; + $this->assertEqual($result, $expected); + + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = mb_strrchr($string, $find, true); + $expected = 'ABCDE'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'Å'; + $result = mb_strrchr($string, $find); + $expected = 'ÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'Å'; + $result = mb_strrchr($string, $find, true); + $expected = 'ÀÁÂÃÄ'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = mb_strrchr($string, $find); + $expected = 'ĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = mb_strrchr($string, $find, true); + $expected = 'ĀĂĄĆĈ'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'F'; + $result = mb_strrchr($string, $find); + $expected = 'FGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'F'; + $result = mb_strrchr($string, $find, true); + $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDE'; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'µ'; + $result = mb_strrchr($string, $find); + $expected = 'µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'µ'; + $result = mb_strrchr($string, $find, true); + $expected = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´'; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'Þ'; + $result = mb_strrchr($string, $find); + $expected = 'Þßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'Þ'; + $result = mb_strrchr($string, $find, true); + $expected = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝ'; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = mb_strrchr($string, $find); + $expected = 'ŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = mb_strrchr($string, $find, true); + $expected = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃń'; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = mb_strrchr($string, $find); + $expected = 'ƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $this->assertEqual($result, $expected); + + $find = 'Ƹ'; + $result = mb_strrchr($string, $find, true); + $expected = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷ'; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'ʀ'; + $result = mb_strrchr($string, $find); + $expected = 'ʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'ʀ'; + $result = mb_strrchr($string, $find, true); + $expected = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿ'; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = mb_strrchr($string, $find); + $expected = 'ЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = mb_strrchr($string, $find, true); + $expected = 'ЀЁЂЃЄЅІ'; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = mb_strrchr($string, $find); + $expected = 'РСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = mb_strrchr($string, $find, true); + $expected = 'МНОП'; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = mb_strrchr($string, $find); + $expected = 'نهوىيًٌٍَُ'; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = mb_strrchr($string, $find, true); + $expected = 'فقكلم'; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = mb_strrchr($string, $find); + $expected = '✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = mb_strrchr($string, $find, true); + $expected = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾'; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = mb_strrchr($string, $find); + $expected = '⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = mb_strrchr($string, $find, true); + $expected = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏'; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = mb_strrchr($string, $find); + $expected = '⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = mb_strrchr($string, $find, true); + $expected = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣'; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = mb_strrchr($string, $find); + $expected = '눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = mb_strrchr($string, $find, true); + $expected = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺'; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = mb_strrchr($string, $find); + $expected = 'ﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = mb_strrchr($string, $find, true); + $expected = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝ'; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = mb_strrchr($string, $find); + $expected = 'ﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = mb_strrchr($string, $find, true); + $expected = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝ'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = mb_strrchr($string, $find); + $expected = 'klmnopqrstuvwxyz'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = mb_strrchr($string, $find, true); + $expected = 'abcdefghij'; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = mb_strrchr($string, $find); + $expected = 'アイウエオカキク'; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = mb_strrchr($string, $find, true); + $expected = '。「」、・ヲァィゥェォャュョッー'; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = mb_strrchr($string, $find); + $expected = 'ハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = mb_strrchr($string, $find, true); + $expected = 'ケコサシスセソタチツテトナニヌネノ'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = mb_strrchr($string, $find); + $expected = 'őřļď!'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = mb_strrchr($string, $find, true); + $expected = 'Ĥēĺļŏ, Ŵ'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = mb_strrchr($string, $find); + $expected = 'orld!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = mb_strrchr($string, $find, true); + $expected = 'Hello, W'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'Wo'; + $result = mb_strrchr($string, $find); + $expected = 'World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'Wo'; + $result = mb_strrchr($string, $find, true); + $expected = 'Hello, '; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'll'; + $result = mb_strrchr($string, $find); + $expected = 'llo, World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'll'; + $result = mb_strrchr($string, $find, true); + $expected = 'He'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'rld'; + $result = mb_strrchr($string, $find); + $expected = 'rld!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'rld'; + $result = mb_strrchr($string, $find, true); + $expected = 'Hello, Wo'; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = mb_strrchr($string, $find); + $expected = 'ni'; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = mb_strrchr($string, $find, true); + $expected = 'či'; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = mb_strrchr($string, $find); + $expected = 'ći'; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = mb_strrchr($string, $find, true); + $expected = 'mo'; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = mb_strrchr($string, $find); + $expected = 'žavni'; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = mb_strrchr($string, $find, true); + $expected = 'dr'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = mb_strrchr($string, $find); + $expected = '设为首页'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = mb_strrchr($string, $find, true); + $expected = '把百度'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = mb_strrchr($string, $find); + $expected = '周永龍'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = mb_strrchr($string, $find, true); + $expected = '一二三'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周龍'; + $result = mb_strrchr($string, $find, true); + $expected = false; + $this->assertEqual($result, $expected); + } + + function testMultibyteStrrchr() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = Multibyte::strrchr($string, $find); + $expected = 'FGHIJKLMNOPQRSTUVWXYZ0123456789'; + $this->assertEqual($result, $expected); + + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'ABCDE'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'Å'; + $result = Multibyte::strrchr($string, $find); + $expected = 'ÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'Å'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'ÀÁÂÃÄ'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = Multibyte::strrchr($string, $find); + $expected = 'ĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'ĀĂĄĆĈ'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'F'; + $result = Multibyte::strrchr($string, $find); + $expected = 'FGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'F'; + $result = Multibyte::strrchr($string, $find, true); + $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDE'; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'µ'; + $result = Multibyte::strrchr($string, $find); + $expected = 'µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'µ'; + $result = Multibyte::strrchr($string, $find, true); + $expected = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´'; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'Þ'; + $result = Multibyte::strrchr($string, $find); + $expected = 'Þßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'Þ'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝ'; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = Multibyte::strrchr($string, $find); + $expected = 'ŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃń'; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = Multibyte::strrchr($string, $find); + $expected = 'ƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $this->assertEqual($result, $expected); + + $find = 'Ƹ'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷ'; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'ʀ'; + $result = Multibyte::strrchr($string, $find); + $expected = 'ʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'ʀ'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿ'; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = Multibyte::strrchr($string, $find); + $expected = 'ЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'ЀЁЂЃЄЅІ'; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = Multibyte::strrchr($string, $find); + $expected = 'РСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'МНОП'; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = Multibyte::strrchr($string, $find); + $expected = 'نهوىيًٌٍَُ'; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'فقكلم'; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = Multibyte::strrchr($string, $find); + $expected = '✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = Multibyte::strrchr($string, $find, true); + $expected = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾'; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = Multibyte::strrchr($string, $find); + $expected = '⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = Multibyte::strrchr($string, $find, true); + $expected = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏'; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = Multibyte::strrchr($string, $find); + $expected = '⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = Multibyte::strrchr($string, $find, true); + $expected = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣'; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = Multibyte::strrchr($string, $find); + $expected = '눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = Multibyte::strrchr($string, $find, true); + $expected = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺'; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = Multibyte::strrchr($string, $find); + $expected = 'ﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝ'; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = Multibyte::strrchr($string, $find); + $expected = 'ﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝ'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = Multibyte::strrchr($string, $find); + $expected = 'klmnopqrstuvwxyz'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'abcdefghij'; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = Multibyte::strrchr($string, $find); + $expected = 'アイウエオカキク'; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = Multibyte::strrchr($string, $find, true); + $expected = '。「」、・ヲァィゥェォャュョッー'; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = Multibyte::strrchr($string, $find); + $expected = 'ハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'ケコサシスセソタチツテトナニヌネノ'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = Multibyte::strrchr($string, $find); + $expected = 'őřļď!'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'Ĥēĺļŏ, Ŵ'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = Multibyte::strrchr($string, $find); + $expected = 'orld!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'Hello, W'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'Wo'; + $result = Multibyte::strrchr($string, $find); + $expected = 'World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'Wo'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'Hello, '; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'll'; + $result = Multibyte::strrchr($string, $find); + $expected = 'llo, World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'll'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'He'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'rld'; + $result = Multibyte::strrchr($string, $find); + $expected = 'rld!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'rld'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'Hello, Wo'; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = Multibyte::strrchr($string, $find); + $expected = 'ni'; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'či'; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = Multibyte::strrchr($string, $find); + $expected = 'ći'; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'mo'; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = Multibyte::strrchr($string, $find); + $expected = 'žavni'; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = Multibyte::strrchr($string, $find, true); + $expected = 'dr'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = Multibyte::strrchr($string, $find); + $expected = '设为首页'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = Multibyte::strrchr($string, $find, true); + $expected = '把百度'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = Multibyte::strrchr($string, $find); + $expected = '周永龍'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = Multibyte::strrchr($string, $find, true); + $expected = '一二三'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周龍'; + $result = Multibyte::strrchr($string, $find, true); + $expected = false; + $this->assertEqual($result, $expected); + } + + function testUsingMbStrrichr() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = mb_strrichr($string, $find); + $expected = 'FGHIJKLMNOPQRSTUVWXYZ0123456789'; + $this->assertEqual($result, $expected); + + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = mb_strrichr($string, $find, true); + $expected = 'ABCDE'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'Å'; + $result = mb_strrichr($string, $find); + $expected = 'ÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'Å'; + $result = mb_strrichr($string, $find, true); + $expected = 'ÀÁÂÃÄ'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = mb_strrichr($string, $find); + $expected = 'ĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = mb_strrichr($string, $find, true); + $expected = 'ĀĂĄĆĈ'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'F'; + $result = mb_strrichr($string, $find); + $expected = 'fghijklmnopqrstuvwxyz{|}~'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'F'; + $result = mb_strrichr($string, $find, true); + $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcde'; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'µ'; + $result = mb_strrichr($string, $find); + $expected = 'µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'µ'; + $result = mb_strrichr($string, $find, true); + $expected = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´'; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'Þ'; + $result = mb_strrichr($string, $find); + $expected = 'þÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'Þ'; + $result = mb_strrichr($string, $find, true); + $expected = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüý'; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = mb_strrichr($string, $find); + $expected = 'ņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = mb_strrichr($string, $find, true); + $expected = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅ'; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = mb_strrichr($string, $find); + $expected = 'ƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $this->assertEqual($result, $expected); + + $find = 'Ƹ'; + $result = mb_strrichr($string, $find, true); + $expected = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸ'; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'ʀ'; + $result = mb_strrichr($string, $find); + $expected = 'ʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'ʀ'; + $result = mb_strrichr($string, $find, true); + $expected = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿ'; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = mb_strrichr($string, $find); + $expected = 'ЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = mb_strrichr($string, $find, true); + $expected = 'ЀЁЂЃЄЅІ'; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = mb_strrichr($string, $find); + $expected = 'рстуфхцчшщъыь'; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмноп'; + $find = 'Р'; + $result = mb_strrichr($string, $find, true); + $expected = 'МНОП'; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = mb_strrichr($string, $find); + $expected = 'نهوىيًٌٍَُ'; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = mb_strrichr($string, $find, true); + $expected = 'فقكلم'; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = mb_strrichr($string, $find); + $expected = '✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = mb_strrichr($string, $find, true); + $expected = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾'; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = mb_strrichr($string, $find); + $expected = '⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = mb_strrichr($string, $find, true); + $expected = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏'; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = mb_strrichr($string, $find); + $expected = '⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = mb_strrichr($string, $find, true); + $expected = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣'; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = mb_strrichr($string, $find); + $expected = '눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = mb_strrichr($string, $find, true); + $expected = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺'; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = mb_strrichr($string, $find); + $expected = 'ﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = mb_strrichr($string, $find, true); + $expected = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝ'; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = mb_strrichr($string, $find); + $expected = 'ﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = mb_strrichr($string, $find, true); + $expected = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝ'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = mb_strrichr($string, $find); + $expected = 'klmnopqrstuvwxyz'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = mb_strrichr($string, $find, true); + $expected = 'abcdefghij'; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = mb_strrichr($string, $find); + $expected = 'アイウエオカキク'; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = mb_strrichr($string, $find, true); + $expected = '。「」、・ヲァィゥェォャュョッー'; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = mb_strrichr($string, $find); + $expected = 'ハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = mb_strrichr($string, $find, true); + $expected = 'ケコサシスセソタチツテトナニヌネノ'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = mb_strrichr($string, $find); + $expected = 'őřļď!'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = mb_strrichr($string, $find, true); + $expected = 'Ĥēĺļŏ, Ŵ'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = mb_strrichr($string, $find); + $expected = 'orld!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = mb_strrichr($string, $find, true); + $expected = 'Hello, W'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'Wo'; + $result = mb_strrichr($string, $find); + $expected = 'World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'Wo'; + $result = mb_strrichr($string, $find, true); + $expected = 'Hello, '; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'll'; + $result = mb_strrichr($string, $find); + $expected = 'llo, World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'll'; + $result = mb_strrichr($string, $find, true); + $expected = 'He'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'rld'; + $result = mb_strrichr($string, $find); + $expected = 'rld!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'rld'; + $result = mb_strrichr($string, $find, true); + $expected = 'Hello, Wo'; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = mb_strrichr($string, $find); + $expected = 'ni'; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = mb_strrichr($string, $find, true); + $expected = 'či'; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = mb_strrichr($string, $find); + $expected = 'ći'; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = mb_strrichr($string, $find, true); + $expected = 'mo'; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = mb_strrichr($string, $find); + $expected = 'žavni'; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = mb_strrichr($string, $find, true); + $expected = 'dr'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = mb_strrichr($string, $find); + $expected = '设为首页'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = mb_strrichr($string, $find, true); + $expected = '把百度'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = mb_strrichr($string, $find); + $expected = '周永龍'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = mb_strrichr($string, $find, true); + $expected = '一二三'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '百设'; + $result = mb_strrichr($string, $find, true); + $expected = false; + $this->assertEqual($result, $expected); + } + + function testMultibyteStrrichr() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = Multibyte::strrichr($string, $find); + $expected = 'FGHIJKLMNOPQRSTUVWXYZ0123456789'; + $this->assertEqual($result, $expected); + + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'ABCDE'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'Å'; + $result = Multibyte::strrichr($string, $find); + $expected = 'ÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'Å'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'ÀÁÂÃÄ'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = Multibyte::strrichr($string, $find); + $expected = 'ĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'ĀĂĄĆĈ'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'F'; + $result = Multibyte::strrichr($string, $find); + $expected = 'fghijklmnopqrstuvwxyz{|}~'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'F'; + $result = Multibyte::strrichr($string, $find, true); + $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcde'; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'µ'; + $result = Multibyte::strrichr($string, $find); + $expected = 'µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'µ'; + $result = Multibyte::strrichr($string, $find, true); + $expected = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´'; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'Þ'; + $result = Multibyte::strrichr($string, $find); + $expected = 'þÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'Þ'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüý'; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = Multibyte::strrichr($string, $find); + $expected = 'ņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅ'; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = Multibyte::strrichr($string, $find); + $expected = 'ƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $this->assertEqual($result, $expected); + + $find = 'Ƹ'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸ'; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'ʀ'; + $result = Multibyte::strrichr($string, $find); + $expected = 'ʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'ʀ'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿ'; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = Multibyte::strrichr($string, $find); + $expected = 'ЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'ЀЁЂЃЄЅІ'; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = Multibyte::strrichr($string, $find); + $expected = 'рстуфхцчшщъыь'; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмноп'; + $find = 'Р'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'МНОП'; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = Multibyte::strrichr($string, $find); + $expected = 'نهوىيًٌٍَُ'; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'فقكلم'; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = Multibyte::strrichr($string, $find); + $expected = '✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = Multibyte::strrichr($string, $find, true); + $expected = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾'; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = Multibyte::strrichr($string, $find); + $expected = '⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = Multibyte::strrichr($string, $find, true); + $expected = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏'; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = Multibyte::strrichr($string, $find); + $expected = '⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = Multibyte::strrichr($string, $find, true); + $expected = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣'; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = Multibyte::strrichr($string, $find); + $expected = '눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = Multibyte::strrichr($string, $find, true); + $expected = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺'; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = Multibyte::strrichr($string, $find); + $expected = 'ﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝ'; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = Multibyte::strrichr($string, $find); + $expected = 'ﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝ'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = Multibyte::strrichr($string, $find); + $expected = 'klmnopqrstuvwxyz'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'abcdefghij'; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = Multibyte::strrichr($string, $find); + $expected = 'アイウエオカキク'; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = Multibyte::strrichr($string, $find, true); + $expected = '。「」、・ヲァィゥェォャュョッー'; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = Multibyte::strrichr($string, $find); + $expected = 'ハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'ケコサシスセソタチツテトナニヌネノ'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = Multibyte::strrichr($string, $find); + $expected = 'őřļď!'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'Ĥēĺļŏ, Ŵ'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = Multibyte::strrichr($string, $find); + $expected = 'orld!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'Hello, W'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'Wo'; + $result = Multibyte::strrichr($string, $find); + $expected = 'World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'Wo'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'Hello, '; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'll'; + $result = Multibyte::strrichr($string, $find); + $expected = 'llo, World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'll'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'He'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'rld'; + $result = Multibyte::strrichr($string, $find); + $expected = 'rld!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'rld'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'Hello, Wo'; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = Multibyte::strrichr($string, $find); + $expected = 'ni'; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'či'; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = Multibyte::strrichr($string, $find); + $expected = 'ći'; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'mo'; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = Multibyte::strrichr($string, $find); + $expected = 'žavni'; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = Multibyte::strrichr($string, $find, true); + $expected = 'dr'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = Multibyte::strrichr($string, $find); + $expected = '设为首页'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = Multibyte::strrichr($string, $find, true); + $expected = '把百度'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = Multibyte::strrichr($string, $find); + $expected = '周永龍'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = Multibyte::strrichr($string, $find, true); + $expected = '一二三'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '百设'; + $result = Multibyte::strrichr($string, $find, true); + $expected = false; + $this->assertEqual($result, $expected); + } + + function testUsingMbStrripos() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = mb_strripos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ABCDEFGHIJKLMNOPQFRSTUVWXYZ0123456789'; + $find = 'F'; + $result = mb_strripos($string, $find, 6); + $expected = 17; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'Å'; + $result = mb_strripos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÅÙÚÛÜÝÞ'; + $find = 'Å'; + $result = mb_strripos($string, $find, 6); + $expected = 24; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÅÙÚÛÜÝÞ'; + $find = 'ÓÔ'; + $result = mb_strripos($string, $find); + $expected = 19; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = mb_strripos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁĊŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = mb_strripos($string, $find, 6); + $expected = 32; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'F'; + $result = mb_strripos($string, $find); + $expected = 69; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'µ'; + $result = mb_strripos($string, $find); + $expected = 20; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'é'; + $result = mb_strripos($string, $find); + $expected = 32; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = mb_strripos($string, $find); + $expected = 25; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = mb_strripos($string, $find); + $expected = 40; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'ƹ'; + $result = mb_strripos($string, $find); + $expected = 40; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'ʀ'; + $result = mb_strripos($string, $find); + $expected = 39; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = mb_strripos($string, $find); + $expected = 7; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = mb_strripos($string, $find); + $expected = 36; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'р'; + $result = mb_strripos($string, $find, 5); + $expected = 36; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = mb_strripos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = mb_strripos($string, $find); + $expected = 15; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = mb_strripos($string, $find); + $expected = 16; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = mb_strripos($string, $find); + $expected = 31; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = mb_strripos($string, $find); + $expected = 26; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = mb_strripos($string, $find); + $expected = 46; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = mb_strripos($string, $find); + $expected = 45; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = mb_strripos($string, $find); + $expected = 10; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = mb_strripos($string, $find); + $expected = 10; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnoppqrstuvwxyz'; + $find = 'pp'; + $result = mb_strripos($string, $find); + $expected = 15; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = mb_strripos($string, $find); + $expected = 16; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = mb_strripos($string, $find); + $expected = 17; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = mb_strripos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = mb_strripos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = mb_strripos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = mb_strripos($string, $find, 5); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = mb_strripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = mb_strripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = mb_strripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = mb_strripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = mb_strripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = mb_strripos($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = mb_strripos($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'dž'; + $result = mb_strripos($string, $find); + $expected = false; + $this->assertEqual($result, $expected); + } + + function testMultibyteStrripos() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = Multibyte::strripos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ABCDEFGHIJKLMNOPQFRSTUVWXYZ0123456789'; + $find = 'F'; + $result = Multibyte::strripos($string, $find, 6); + $expected = 17; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'Å'; + $result = Multibyte::strripos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÅÙÚÛÜÝÞ'; + $find = 'Å'; + $result = Multibyte::strripos($string, $find, 6); + $expected = 24; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÅÙÚÛÜÝÞ'; + $find = 'ÓÔ'; + $result = Multibyte::strripos($string, $find); + $expected = 19; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = Multibyte::strripos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁĊŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = Multibyte::strripos($string, $find, 6); + $expected = 32; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'F'; + $result = Multibyte::strripos($string, $find); + $expected = 69; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'µ'; + $result = Multibyte::strripos($string, $find); + $expected = 20; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'é'; + $result = Multibyte::strripos($string, $find); + $expected = 32; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = Multibyte::strripos($string, $find); + $expected = 25; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = Multibyte::strripos($string, $find); + $expected = 40; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'ƹ'; + $result = Multibyte::strripos($string, $find); + $expected = 40; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'ʀ'; + $result = Multibyte::strripos($string, $find); + $expected = 39; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = Multibyte::strripos($string, $find); + $expected = 7; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = Multibyte::strripos($string, $find); + $expected = 36; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'р'; + $result = Multibyte::strripos($string, $find, 5); + $expected = 36; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = Multibyte::strripos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = Multibyte::strripos($string, $find); + $expected = 15; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = Multibyte::strripos($string, $find); + $expected = 16; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = Multibyte::strripos($string, $find); + $expected = 31; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = Multibyte::strripos($string, $find); + $expected = 26; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = Multibyte::strripos($string, $find); + $expected = 46; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = Multibyte::strripos($string, $find); + $expected = 45; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = Multibyte::strripos($string, $find); + $expected = 10; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = Multibyte::strripos($string, $find); + $expected = 10; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnoppqrstuvwxyz'; + $find = 'pp'; + $result = Multibyte::strripos($string, $find); + $expected = 15; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = Multibyte::strripos($string, $find); + $expected = 16; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = Multibyte::strripos($string, $find); + $expected = 17; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = Multibyte::strripos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = Multibyte::strripos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = Multibyte::strripos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = Multibyte::strripos($string, $find, 5); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = Multibyte::strripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = Multibyte::strripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = Multibyte::strripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = Multibyte::strripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = Multibyte::strripos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = Multibyte::strripos($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = Multibyte::strripos($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'dž'; + $result = Multibyte::strripos($string, $find); + $expected = false; + $this->assertEqual($result, $expected); + } + + function testUsingMbStrrpos() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = mb_strrpos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ABCDEFGHIJKLMNOPQFRSTUVWXYZ0123456789'; + $find = 'F'; + $result = mb_strrpos($string, $find, 6); + $expected = 17; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'Å'; + $result = mb_strrpos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÅÙÚÛÜÝÞ'; + $find = 'ÙÚ'; + $result = mb_strrpos($string, $find); + $expected = 25; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÅÙÚÛÜÝÞ'; + $find = 'Å'; + $result = mb_strrpos($string, $find, 6); + $expected = 24; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = mb_strrpos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁĊŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = mb_strrpos($string, $find, 6); + $expected = 32; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'F'; + $result = mb_strrpos($string, $find); + $expected = 37; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'µ'; + $result = mb_strrpos($string, $find); + $expected = 20; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'é'; + $result = mb_strrpos($string, $find); + $expected = 32; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = mb_strrpos($string, $find); + $expected = 24; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = mb_strrpos($string, $find); + $expected = 39; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'ƹ'; + $result = mb_strrpos($string, $find); + $expected = 40; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'ʀ'; + $result = mb_strrpos($string, $find); + $expected = 39; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = mb_strrpos($string, $find); + $expected = 7; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = mb_strrpos($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'р'; + $result = mb_strrpos($string, $find, 5); + $expected = 36; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = mb_strrpos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = mb_strrpos($string, $find); + $expected = 15; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = mb_strrpos($string, $find); + $expected = 16; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = mb_strrpos($string, $find); + $expected = 31; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = mb_strrpos($string, $find); + $expected = 26; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = mb_strrpos($string, $find); + $expected = 46; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = mb_strrpos($string, $find); + $expected = 45; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = mb_strrpos($string, $find); + $expected = 10; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = mb_strrpos($string, $find); + $expected = 10; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnoppqrstuvwxyz'; + $find = 'pp'; + $result = mb_strrpos($string, $find); + $expected = 15; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = mb_strrpos($string, $find); + $expected = 16; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = mb_strrpos($string, $find); + $expected = 17; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = mb_strrpos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = mb_strrpos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = mb_strrpos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = mb_strrpos($string, $find, 5); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = mb_strrpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = mb_strrpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = mb_strrpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = mb_strrpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = mb_strrpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = mb_strrpos($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = mb_strrpos($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'H'; + $result = mb_strrpos($string, $find); + $expected = false; + $this->assertEqual($result, $expected); + } + + function testMultibyteStrrpos() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = Multibyte::strrpos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ABCDEFGHIJKLMNOPQFRSTUVWXYZ0123456789'; + $find = 'F'; + $result = Multibyte::strrpos($string, $find, 6); + $expected = 17; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'Å'; + $result = Multibyte::strrpos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÅÙÚÛÜÝÞ'; + $find = 'Å'; + $result = Multibyte::strrpos($string, $find, 6); + $expected = 24; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÅÙÚÛÜÝÞ'; + $find = 'ÙÚ'; + $result = Multibyte::strrpos($string, $find); + $expected = 25; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = Multibyte::strrpos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁĊŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = Multibyte::strrpos($string, $find, 6); + $expected = 32; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'F'; + $result = Multibyte::strrpos($string, $find); + $expected = 37; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'µ'; + $result = Multibyte::strrpos($string, $find); + $expected = 20; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'é'; + $result = Multibyte::strrpos($string, $find); + $expected = 32; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = Multibyte::strrpos($string, $find); + $expected = 24; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = Multibyte::strrpos($string, $find); + $expected = 39; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'ƹ'; + $result = Multibyte::strrpos($string, $find); + $expected = 40; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'ʀ'; + $result = Multibyte::strrpos($string, $find); + $expected = 39; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = Multibyte::strrpos($string, $find); + $expected = 7; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = Multibyte::strrpos($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'р'; + $result = Multibyte::strrpos($string, $find, 5); + $expected = 36; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = Multibyte::strrpos($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = Multibyte::strrpos($string, $find); + $expected = 15; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = Multibyte::strrpos($string, $find); + $expected = 16; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = Multibyte::strrpos($string, $find); + $expected = 31; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = Multibyte::strrpos($string, $find); + $expected = 26; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = Multibyte::strrpos($string, $find); + $expected = 46; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = Multibyte::strrpos($string, $find); + $expected = 45; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = Multibyte::strrpos($string, $find); + $expected = 10; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = Multibyte::strrpos($string, $find); + $expected = 10; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnoppqrstuvwxyz'; + $find = 'pp'; + $result = Multibyte::strrpos($string, $find); + $expected = 15; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = Multibyte::strrpos($string, $find); + $expected = 16; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = Multibyte::strrpos($string, $find); + $expected = 17; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = Multibyte::strrpos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = Multibyte::strrpos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = Multibyte::strrpos($string, $find); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = Multibyte::strrpos($string, $find, 5); + $expected = 8; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = Multibyte::strrpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = Multibyte::strrpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = Multibyte::strrpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = Multibyte::strrpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = Multibyte::strrpos($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = Multibyte::strrpos($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = Multibyte::strrpos($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'H'; + $result = Multibyte::strrpos($string, $find); + $expected = false; + $this->assertEqual($result, $expected); + } + + function testUsingMbStrstr() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = mb_strstr($string, $find); + $expected = 'FGHIJKLMNOPQRSTUVWXYZ0123456789'; + $this->assertEqual($result, $expected); + + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = mb_strstr($string, $find, true); + $expected = 'ABCDE'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'Å'; + $result = mb_strstr($string, $find); + $expected = 'ÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'Å'; + $result = mb_strstr($string, $find, true); + $expected = 'ÀÁÂÃÄ'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = mb_strstr($string, $find); + $expected = 'ĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = mb_strstr($string, $find, true); + $expected = 'ĀĂĄĆĈ'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'F'; + $result = mb_strstr($string, $find); + $expected = 'FGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'F'; + $result = mb_strstr($string, $find, true); + $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDE'; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'µ'; + $result = mb_strstr($string, $find); + $expected = 'µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'µ'; + $result = mb_strstr($string, $find, true); + $expected = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´'; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'Þ'; + $result = mb_strstr($string, $find); + $expected = 'Þßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'Þ'; + $result = mb_strstr($string, $find, true); + $expected = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝ'; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = mb_strstr($string, $find); + $expected = 'ŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = mb_strstr($string, $find, true); + $expected = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃń'; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = mb_strstr($string, $find); + $expected = 'ƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $this->assertEqual($result, $expected); + + $find = 'Ƹ'; + $result = mb_strstr($string, $find, true); + $expected = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷ'; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'ʀ'; + $result = mb_strstr($string, $find); + $expected = 'ʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'ʀ'; + $result = mb_strstr($string, $find, true); + $expected = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿ'; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = mb_strstr($string, $find); + $expected = 'ЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = mb_strstr($string, $find, true); + $expected = 'ЀЁЂЃЄЅІ'; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = mb_strstr($string, $find); + $expected = 'РСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = mb_strstr($string, $find, true); + $expected = 'МНОП'; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = mb_strstr($string, $find); + $expected = 'نهوىيًٌٍَُ'; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = mb_strstr($string, $find, true); + $expected = 'فقكلم'; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = mb_strstr($string, $find); + $expected = '✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = mb_strstr($string, $find, true); + $expected = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾'; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = mb_strstr($string, $find); + $expected = '⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = mb_strstr($string, $find, true); + $expected = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏'; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = mb_strstr($string, $find); + $expected = '⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = mb_strstr($string, $find, true); + $expected = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣'; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = mb_strstr($string, $find); + $expected = '눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = mb_strstr($string, $find, true); + $expected = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺'; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = mb_strstr($string, $find); + $expected = 'ﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = mb_strstr($string, $find, true); + $expected = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝ'; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = mb_strstr($string, $find); + $expected = 'ﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = mb_strstr($string, $find, true); + $expected = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝ'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = mb_strstr($string, $find); + $expected = 'klmnopqrstuvwxyz'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = mb_strstr($string, $find, true); + $expected = 'abcdefghij'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'K'; + $result = mb_strstr($string, $find); + $expected = false; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = mb_strstr($string, $find); + $expected = 'アイウエオカキク'; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = mb_strstr($string, $find, true); + $expected = '。「」、・ヲァィゥェォャュョッー'; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = mb_strstr($string, $find); + $expected = 'ハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = mb_strstr($string, $find, true); + $expected = 'ケコサシスセソタチツテトナニヌネノ'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = mb_strstr($string, $find); + $expected = 'őřļď!'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = mb_strstr($string, $find, true); + $expected = 'Ĥēĺļŏ, Ŵ'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ĺļ'; + $result = mb_strstr($string, $find, true); + $expected = 'Ĥē'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = mb_strstr($string, $find); + $expected = 'o, World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = mb_strstr($string, $find, true); + $expected = 'Hell'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'Wo'; + $result = mb_strstr($string, $find); + $expected = 'World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'Wo'; + $result = mb_strstr($string, $find, true); + $expected = 'Hello, '; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'll'; + $result = mb_strstr($string, $find); + $expected = 'llo, World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'll'; + $result = mb_strstr($string, $find, true); + $expected = 'He'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'rld'; + $result = mb_strstr($string, $find); + $expected = 'rld!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'rld'; + $result = mb_strstr($string, $find, true); + $expected = 'Hello, Wo'; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = mb_strstr($string, $find); + $expected = 'ni'; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = mb_strstr($string, $find, true); + $expected = 'či'; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = mb_strstr($string, $find); + $expected = 'ći'; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = mb_strstr($string, $find, true); + $expected = 'mo'; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = mb_strstr($string, $find); + $expected = 'žavni'; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = mb_strstr($string, $find, true); + $expected = 'dr'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = mb_strstr($string, $find); + $expected = '设为首页'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = mb_strstr($string, $find, true); + $expected = '把百度'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = mb_strstr($string, $find); + $expected = '周永龍'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = mb_strstr($string, $find, true); + $expected = '一二三'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '二周'; + $result = mb_strstr($string, $find); + $expected = false; + $this->assertEqual($result, $expected); + } + + function testMultibyteStrstr() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = Multibyte::strstr($string, $find); + $expected = 'FGHIJKLMNOPQRSTUVWXYZ0123456789'; + $this->assertEqual($result, $expected); + + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'ABCDE'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'Å'; + $result = Multibyte::strstr($string, $find); + $expected = 'ÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $find = 'Å'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'ÀÁÂÃÄ'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = Multibyte::strstr($string, $find); + $expected = 'ĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'ĀĂĄĆĈ'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'F'; + $result = Multibyte::strstr($string, $find); + $expected = 'FGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $find = 'F'; + $result = Multibyte::strstr($string, $find, true); + $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDE'; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'µ'; + $result = Multibyte::strstr($string, $find); + $expected = 'µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $find = 'µ'; + $result = Multibyte::strstr($string, $find, true); + $expected = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´'; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'Þ'; + $result = Multibyte::strstr($string, $find); + $expected = 'Þßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $find = 'Þ'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝ'; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = Multibyte::strstr($string, $find); + $expected = 'ŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'Ņ'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃń'; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = Multibyte::strstr($string, $find); + $expected = 'ƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $this->assertEqual($result, $expected); + + $find = 'Ƹ'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷ'; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'ʀ'; + $result = Multibyte::strstr($string, $find); + $expected = 'ʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $find = 'ʀ'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿ'; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = Multibyte::strstr($string, $find); + $expected = 'ЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'ЀЁЂЃЄЅІ'; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = Multibyte::strstr($string, $find); + $expected = 'РСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'МНОП'; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = Multibyte::strstr($string, $find); + $expected = 'نهوىيًٌٍَُ'; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $find = 'ن'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'فقكلم'; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = Multibyte::strstr($string, $find); + $expected = '✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = Multibyte::strstr($string, $find, true); + $expected = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾'; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = Multibyte::strstr($string, $find); + $expected = '⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = Multibyte::strstr($string, $find, true); + $expected = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏'; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = Multibyte::strstr($string, $find); + $expected = '⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = Multibyte::strstr($string, $find, true); + $expected = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣'; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = Multibyte::strstr($string, $find); + $expected = '눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눻'; + $result = Multibyte::strstr($string, $find, true); + $expected = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺'; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = Multibyte::strstr($string, $find); + $expected = 'ﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞ'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝ'; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = Multibyte::strstr($string, $find); + $expected = 'ﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $find = 'ﻞ'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝ'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = Multibyte::strstr($string, $find); + $expected = 'klmnopqrstuvwxyz'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'k'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'abcdefghij'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $find = 'K'; + $result = Multibyte::strstr($string, $find); + $expected = false; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = Multibyte::strstr($string, $find); + $expected = 'アイウエオカキク'; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = Multibyte::strstr($string, $find, true); + $expected = '。「」、・ヲァィゥェォャュョッー'; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = Multibyte::strstr($string, $find); + $expected = 'ハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'ケコサシスセソタチツテトナニヌネノ'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = Multibyte::strstr($string, $find); + $expected = 'őřļď!'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'Ĥēĺļŏ, Ŵ'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ĺļ'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'Ĥē'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = Multibyte::strstr($string, $find); + $expected = 'o, World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'Hell'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'Wo'; + $result = Multibyte::strstr($string, $find); + $expected = 'World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'Wo'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'Hello, '; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'll'; + $result = Multibyte::strstr($string, $find); + $expected = 'llo, World!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'll'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'He'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'rld'; + $result = Multibyte::strstr($string, $find); + $expected = 'rld!'; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'rld'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'Hello, Wo'; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = Multibyte::strstr($string, $find); + $expected = 'ni'; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'či'; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = Multibyte::strstr($string, $find); + $expected = 'ći'; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'mo'; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = Multibyte::strstr($string, $find); + $expected = 'žavni'; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = Multibyte::strstr($string, $find, true); + $expected = 'dr'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = Multibyte::strstr($string, $find); + $expected = '设为首页'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = Multibyte::strstr($string, $find, true); + $expected = '把百度'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = Multibyte::strstr($string, $find); + $expected = '周永龍'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = Multibyte::strstr($string, $find, true); + $expected = '一二三'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '二周'; + $result = Multibyte::strstr($string, $find); + $expected = false; + $this->assertEqual($result, $expected); + } + + function testUsingMbStrtolower() { + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~'; + $result = mb_strtolower($string); + $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@'; + $result = mb_strtolower($string); + $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@'; + $this->assertEqual($result, $expected); + + $string = 'À'; + $result = mb_strtolower($string); + $expected = 'à'; + $this->assertEqual($result, $expected); + + $string = 'Á'; + $result = mb_strtolower($string); + $expected = 'á'; + $this->assertEqual($result, $expected); + + $string = 'Â'; + $result = mb_strtolower($string); + $expected = 'â'; + $this->assertEqual($result, $expected); + + $string = 'Ã'; + $result = mb_strtolower($string); + $expected = 'ã'; + $this->assertEqual($result, $expected); + + $string = 'Ä'; + $result = mb_strtolower($string); + $expected = 'ä'; + $this->assertEqual($result, $expected); + + $string = 'Å'; + $result = mb_strtolower($string); + $expected = 'å'; + $this->assertEqual($result, $expected); + + $string = 'Æ'; + $result = mb_strtolower($string); + $expected = 'æ'; + $this->assertEqual($result, $expected); + + $string = 'Ç'; + $result = mb_strtolower($string); + $expected = 'ç'; + $this->assertEqual($result, $expected); + + $string = 'È'; + $result = mb_strtolower($string); + $expected = 'è'; + $this->assertEqual($result, $expected); + + $string = 'É'; + $result = mb_strtolower($string); + $expected = 'é'; + $this->assertEqual($result, $expected); + + $string = 'Ê'; + $result = mb_strtolower($string); + $expected = 'ê'; + $this->assertEqual($result, $expected); + + $string = 'Ë'; + $result = mb_strtolower($string); + $expected = 'ë'; + $this->assertEqual($result, $expected); + + $string = 'Ì'; + $result = mb_strtolower($string); + $expected = 'ì'; + $this->assertEqual($result, $expected); + + $string = 'Í'; + $result = mb_strtolower($string); + $expected = 'í'; + $this->assertEqual($result, $expected); + + $string = 'Î'; + $result = mb_strtolower($string); + $expected = 'î'; + $this->assertEqual($result, $expected); + + $string = 'Ï'; + $result = mb_strtolower($string); + $expected = 'ï'; + $this->assertEqual($result, $expected); + + $string = 'Ð'; + $result = mb_strtolower($string); + $expected = 'ð'; + $this->assertEqual($result, $expected); + + $string = 'Ñ'; + $result = mb_strtolower($string); + $expected = 'ñ'; + $this->assertEqual($result, $expected); + + $string = 'Ò'; + $result = mb_strtolower($string); + $expected = 'ò'; + $this->assertEqual($result, $expected); + + $string = 'Ó'; + $result = mb_strtolower($string); + $expected = 'ó'; + $this->assertEqual($result, $expected); + + $string = 'Ô'; + $result = mb_strtolower($string); + $expected = 'ô'; + $this->assertEqual($result, $expected); + + $string = 'Õ'; + $result = mb_strtolower($string); + $expected = 'õ'; + $this->assertEqual($result, $expected); + + $string = 'Ö'; + $result = mb_strtolower($string); + $expected = 'ö'; + $this->assertEqual($result, $expected); + + $string = 'Ø'; + $result = mb_strtolower($string); + $expected = 'ø'; + $this->assertEqual($result, $expected); + + $string = 'Ù'; + $result = mb_strtolower($string); + $expected = 'ù'; + $this->assertEqual($result, $expected); + + $string = 'Ú'; + $result = mb_strtolower($string); + $expected = 'ú'; + $this->assertEqual($result, $expected); + + $string = 'Û'; + $result = mb_strtolower($string); + $expected = 'û'; + $this->assertEqual($result, $expected); + + $string = 'Ü'; + $result = mb_strtolower($string); + $expected = 'ü'; + $this->assertEqual($result, $expected); + + $string = 'Ý'; + $result = mb_strtolower($string); + $expected = 'ý'; + $this->assertEqual($result, $expected); + + $string = 'Þ'; + $result = mb_strtolower($string); + $expected = 'þ'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $result = mb_strtolower($string); + $expected = 'àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ'; + $this->assertEqual($result, $expected); + + $string = 'Ā'; + $result = mb_strtolower($string); + $expected = 'ā'; + $this->assertEqual($result, $expected); + + $string = 'Ă'; + $result = mb_strtolower($string); + $expected = 'ă'; + $this->assertEqual($result, $expected); + + $string = 'Ą'; + $result = mb_strtolower($string); + $expected = 'ą'; + $this->assertEqual($result, $expected); + + $string = 'Ć'; + $result = mb_strtolower($string); + $expected = 'ć'; + $this->assertEqual($result, $expected); + + $string = 'Ĉ'; + $result = mb_strtolower($string); + $expected = 'ĉ'; + $this->assertEqual($result, $expected); + + $string = 'Ċ'; + $result = mb_strtolower($string); + $expected = 'ċ'; + $this->assertEqual($result, $expected); + + $string = 'Č'; + $result = mb_strtolower($string); + $expected = 'č'; + $this->assertEqual($result, $expected); + + $string = 'Ď'; + $result = mb_strtolower($string); + $expected = 'ď'; + $this->assertEqual($result, $expected); + + $string = 'Đ'; + $result = mb_strtolower($string); + $expected = 'đ'; + $this->assertEqual($result, $expected); + + $string = 'Ē'; + $result = mb_strtolower($string); + $expected = 'ē'; + $this->assertEqual($result, $expected); + + $string = 'Ĕ'; + $result = mb_strtolower($string); + $expected = 'ĕ'; + $this->assertEqual($result, $expected); + + $string = 'Ė'; + $result = mb_strtolower($string); + $expected = 'ė'; + $this->assertEqual($result, $expected); + + $string = 'Ę'; + $result = mb_strtolower($string); + $expected = 'ę'; + $this->assertEqual($result, $expected); + + $string = 'Ě'; + $result = mb_strtolower($string); + $expected = 'ě'; + $this->assertEqual($result, $expected); + + $string = 'Ĝ'; + $result = mb_strtolower($string); + $expected = 'ĝ'; + $this->assertEqual($result, $expected); + + $string = 'Ğ'; + $result = mb_strtolower($string); + $expected = 'ğ'; + $this->assertEqual($result, $expected); + + $string = 'Ġ'; + $result = mb_strtolower($string); + $expected = 'ġ'; + $this->assertEqual($result, $expected); + + $string = 'Ģ'; + $result = mb_strtolower($string); + $expected = 'ģ'; + $this->assertEqual($result, $expected); + + $string = 'Ĥ'; + $result = mb_strtolower($string); + $expected = 'ĥ'; + $this->assertEqual($result, $expected); + + $string = 'Ħ'; + $result = mb_strtolower($string); + $expected = 'ħ'; + $this->assertEqual($result, $expected); + + $string = 'Ĩ'; + $result = mb_strtolower($string); + $expected = 'ĩ'; + $this->assertEqual($result, $expected); + + $string = 'Ī'; + $result = mb_strtolower($string); + $expected = 'ī'; + $this->assertEqual($result, $expected); + + $string = 'Ĭ'; + $result = mb_strtolower($string); + $expected = 'ĭ'; + $this->assertEqual($result, $expected); + + $string = 'Į'; + $result = mb_strtolower($string); + $expected = 'į'; + $this->assertEqual($result, $expected); + + $string = 'IJ'; + $result = mb_strtolower($string); + $expected = 'ij'; + $this->assertEqual($result, $expected); + + $string = 'Ĵ'; + $result = mb_strtolower($string); + $expected = 'ĵ'; + $this->assertEqual($result, $expected); + + $string = 'Ķ'; + $result = mb_strtolower($string); + $expected = 'ķ'; + $this->assertEqual($result, $expected); + + $string = 'Ĺ'; + $result = mb_strtolower($string); + $expected = 'ĺ'; + $this->assertEqual($result, $expected); + + $string = 'Ļ'; + $result = mb_strtolower($string); + $expected = 'ļ'; + $this->assertEqual($result, $expected); + + $string = 'Ľ'; + $result = mb_strtolower($string); + $expected = 'ľ'; + $this->assertEqual($result, $expected); + + $string = 'Ŀ'; + $result = mb_strtolower($string); + $expected = 'ŀ'; + $this->assertEqual($result, $expected); + + $string = 'Ł'; + $result = mb_strtolower($string); + $expected = 'ł'; + $this->assertEqual($result, $expected); + + $string = 'Ń'; + $result = mb_strtolower($string); + $expected = 'ń'; + $this->assertEqual($result, $expected); + + $string = 'Ņ'; + $result = mb_strtolower($string); + $expected = 'ņ'; + $this->assertEqual($result, $expected); + + $string = 'Ň'; + $result = mb_strtolower($string); + $expected = 'ň'; + $this->assertEqual($result, $expected); + + $string = 'Ŋ'; + $result = mb_strtolower($string); + $expected = 'ŋ'; + $this->assertEqual($result, $expected); + + $string = 'Ō'; + $result = mb_strtolower($string); + $expected = 'ō'; + $this->assertEqual($result, $expected); + + $string = 'Ŏ'; + $result = mb_strtolower($string); + $expected = 'ŏ'; + $this->assertEqual($result, $expected); + + $string = 'Ő'; + $result = mb_strtolower($string); + $expected = 'ő'; + $this->assertEqual($result, $expected); + + $string = 'Œ'; + $result = mb_strtolower($string); + $expected = 'œ'; + $this->assertEqual($result, $expected); + + $string = 'Ŕ'; + $result = mb_strtolower($string); + $expected = 'ŕ'; + $this->assertEqual($result, $expected); + + $string = 'Ŗ'; + $result = mb_strtolower($string); + $expected = 'ŗ'; + $this->assertEqual($result, $expected); + + $string = 'Ř'; + $result = mb_strtolower($string); + $expected = 'ř'; + $this->assertEqual($result, $expected); + + $string = 'Ś'; + $result = mb_strtolower($string); + $expected = 'ś'; + $this->assertEqual($result, $expected); + + $string = 'Ŝ'; + $result = mb_strtolower($string); + $expected = 'ŝ'; + $this->assertEqual($result, $expected); + + $string = 'Ş'; + $result = mb_strtolower($string); + $expected = 'ş'; + $this->assertEqual($result, $expected); + + $string = 'Š'; + $result = mb_strtolower($string); + $expected = 'š'; + $this->assertEqual($result, $expected); + + $string = 'Ţ'; + $result = mb_strtolower($string); + $expected = 'ţ'; + $this->assertEqual($result, $expected); + + $string = 'Ť'; + $result = mb_strtolower($string); + $expected = 'ť'; + $this->assertEqual($result, $expected); + + $string = 'Ŧ'; + $result = mb_strtolower($string); + $expected = 'ŧ'; + $this->assertEqual($result, $expected); + + $string = 'Ũ'; + $result = mb_strtolower($string); + $expected = 'ũ'; + $this->assertEqual($result, $expected); + + $string = 'Ū'; + $result = mb_strtolower($string); + $expected = 'ū'; + $this->assertEqual($result, $expected); + + $string = 'Ŭ'; + $result = mb_strtolower($string); + $expected = 'ŭ'; + $this->assertEqual($result, $expected); + + $string = 'Ů'; + $result = mb_strtolower($string); + $expected = 'ů'; + $this->assertEqual($result, $expected); + + $string = 'Ű'; + $result = mb_strtolower($string); + $expected = 'ű'; + $this->assertEqual($result, $expected); + + $string = 'Ų'; + $result = mb_strtolower($string); + $expected = 'ų'; + $this->assertEqual($result, $expected); + + $string = 'Ŵ'; + $result = mb_strtolower($string); + $expected = 'ŵ'; + $this->assertEqual($result, $expected); + + $string = 'Ŷ'; + $result = mb_strtolower($string); + $expected = 'ŷ'; + $this->assertEqual($result, $expected); + + $string = 'Ź'; + $result = mb_strtolower($string); + $expected = 'ź'; + $this->assertEqual($result, $expected); + + $string = 'Ż'; + $result = mb_strtolower($string); + $expected = 'ż'; + $this->assertEqual($result, $expected); + + $string = 'Ž'; + $result = mb_strtolower($string); + $expected = 'ž'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $result = mb_strtolower($string); + $expected = 'āăąćĉċčďđēĕėęěĝğġģĥħĩīĭįijĵķĺļľŀłńņňŋōŏőœŕŗřśŝşšţťŧũūŭůűųŵŷźżž'; + $this->assertEqual($result, $expected); + + $string = 'ĤĒĹĻŎ, ŴŐŘĻĎ!'; + $result = mb_strtolower($string); + $expected = 'ĥēĺļŏ, ŵőřļď!'; + $this->assertEqual($result, $expected); + + $string = 'ĥēĺļŏ, ŵőřļď!'; + $result = mb_strtolower($string); + $expected = 'ĥēĺļŏ, ŵőřļď!'; + $this->assertEqual($result, $expected); + + $string = 'ἈΙ'; + $result = mb_strtolower($string); + $expected = 'ἀι'; + $this->assertEqual($result, $expected); + } + + function testMultibyteStrtolower() { + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~'; + $result = Multibyte::strtolower($string); + $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@'; + $result = Multibyte::strtolower($string); + $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@'; + $this->assertEqual($result, $expected); + + $string = 'À'; + $result = Multibyte::strtolower($string); + $expected = 'à'; + $this->assertEqual($result, $expected); + + $string = 'Á'; + $result = Multibyte::strtolower($string); + $expected = 'á'; + $this->assertEqual($result, $expected); + + $string = 'Â'; + $result = Multibyte::strtolower($string); + $expected = 'â'; + $this->assertEqual($result, $expected); + + $string = 'Ã'; + $result = Multibyte::strtolower($string); + $expected = 'ã'; + $this->assertEqual($result, $expected); + + $string = 'Ä'; + $result = Multibyte::strtolower($string); + $expected = 'ä'; + $this->assertEqual($result, $expected); + + $string = 'Å'; + $result = Multibyte::strtolower($string); + $expected = 'å'; + $this->assertEqual($result, $expected); + + $string = 'Æ'; + $result = Multibyte::strtolower($string); + $expected = 'æ'; + $this->assertEqual($result, $expected); + + $string = 'Ç'; + $result = Multibyte::strtolower($string); + $expected = 'ç'; + $this->assertEqual($result, $expected); + + $string = 'È'; + $result = Multibyte::strtolower($string); + $expected = 'è'; + $this->assertEqual($result, $expected); + + $string = 'É'; + $result = Multibyte::strtolower($string); + $expected = 'é'; + $this->assertEqual($result, $expected); + + $string = 'Ê'; + $result = Multibyte::strtolower($string); + $expected = 'ê'; + $this->assertEqual($result, $expected); + + $string = 'Ë'; + $result = Multibyte::strtolower($string); + $expected = 'ë'; + $this->assertEqual($result, $expected); + + $string = 'Ì'; + $result = Multibyte::strtolower($string); + $expected = 'ì'; + $this->assertEqual($result, $expected); + + $string = 'Í'; + $result = Multibyte::strtolower($string); + $expected = 'í'; + $this->assertEqual($result, $expected); + + $string = 'Î'; + $result = Multibyte::strtolower($string); + $expected = 'î'; + $this->assertEqual($result, $expected); + + $string = 'Ï'; + $result = Multibyte::strtolower($string); + $expected = 'ï'; + $this->assertEqual($result, $expected); + + $string = 'Ð'; + $result = Multibyte::strtolower($string); + $expected = 'ð'; + $this->assertEqual($result, $expected); + + $string = 'Ñ'; + $result = Multibyte::strtolower($string); + $expected = 'ñ'; + $this->assertEqual($result, $expected); + + $string = 'Ò'; + $result = Multibyte::strtolower($string); + $expected = 'ò'; + $this->assertEqual($result, $expected); + + $string = 'Ó'; + $result = Multibyte::strtolower($string); + $expected = 'ó'; + $this->assertEqual($result, $expected); + + $string = 'Ô'; + $result = Multibyte::strtolower($string); + $expected = 'ô'; + $this->assertEqual($result, $expected); + + $string = 'Õ'; + $result = Multibyte::strtolower($string); + $expected = 'õ'; + $this->assertEqual($result, $expected); + + $string = 'Ö'; + $result = Multibyte::strtolower($string); + $expected = 'ö'; + $this->assertEqual($result, $expected); + + $string = 'Ø'; + $result = Multibyte::strtolower($string); + $expected = 'ø'; + $this->assertEqual($result, $expected); + + $string = 'Ù'; + $result = Multibyte::strtolower($string); + $expected = 'ù'; + $this->assertEqual($result, $expected); + + $string = 'Ú'; + $result = Multibyte::strtolower($string); + $expected = 'ú'; + $this->assertEqual($result, $expected); + + $string = 'Û'; + $result = Multibyte::strtolower($string); + $expected = 'û'; + $this->assertEqual($result, $expected); + + $string = 'Ü'; + $result = Multibyte::strtolower($string); + $expected = 'ü'; + $this->assertEqual($result, $expected); + + $string = 'Ý'; + $result = Multibyte::strtolower($string); + $expected = 'ý'; + $this->assertEqual($result, $expected); + + $string = 'Þ'; + $result = Multibyte::strtolower($string); + $expected = 'þ'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $result = Multibyte::strtolower($string); + $expected = 'àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ'; + $this->assertEqual($result, $expected); + + $string = 'Ā'; + $result = Multibyte::strtolower($string); + $expected = 'ā'; + $this->assertEqual($result, $expected); + + $string = 'Ă'; + $result = Multibyte::strtolower($string); + $expected = 'ă'; + $this->assertEqual($result, $expected); + + $string = 'Ą'; + $result = Multibyte::strtolower($string); + $expected = 'ą'; + $this->assertEqual($result, $expected); + + $string = 'Ć'; + $result = Multibyte::strtolower($string); + $expected = 'ć'; + $this->assertEqual($result, $expected); + + $string = 'Ĉ'; + $result = Multibyte::strtolower($string); + $expected = 'ĉ'; + $this->assertEqual($result, $expected); + + $string = 'Ċ'; + $result = Multibyte::strtolower($string); + $expected = 'ċ'; + $this->assertEqual($result, $expected); + + $string = 'Č'; + $result = Multibyte::strtolower($string); + $expected = 'č'; + $this->assertEqual($result, $expected); + + $string = 'Ď'; + $result = Multibyte::strtolower($string); + $expected = 'ď'; + $this->assertEqual($result, $expected); + + $string = 'Đ'; + $result = Multibyte::strtolower($string); + $expected = 'đ'; + $this->assertEqual($result, $expected); + + $string = 'Ē'; + $result = Multibyte::strtolower($string); + $expected = 'ē'; + $this->assertEqual($result, $expected); + + $string = 'Ĕ'; + $result = Multibyte::strtolower($string); + $expected = 'ĕ'; + $this->assertEqual($result, $expected); + + $string = 'Ė'; + $result = Multibyte::strtolower($string); + $expected = 'ė'; + $this->assertEqual($result, $expected); + + $string = 'Ę'; + $result = Multibyte::strtolower($string); + $expected = 'ę'; + $this->assertEqual($result, $expected); + + $string = 'Ě'; + $result = Multibyte::strtolower($string); + $expected = 'ě'; + $this->assertEqual($result, $expected); + + $string = 'Ĝ'; + $result = Multibyte::strtolower($string); + $expected = 'ĝ'; + $this->assertEqual($result, $expected); + + $string = 'Ğ'; + $result = Multibyte::strtolower($string); + $expected = 'ğ'; + $this->assertEqual($result, $expected); + + $string = 'Ġ'; + $result = Multibyte::strtolower($string); + $expected = 'ġ'; + $this->assertEqual($result, $expected); + + $string = 'Ģ'; + $result = Multibyte::strtolower($string); + $expected = 'ģ'; + $this->assertEqual($result, $expected); + + $string = 'Ĥ'; + $result = Multibyte::strtolower($string); + $expected = 'ĥ'; + $this->assertEqual($result, $expected); + + $string = 'Ħ'; + $result = Multibyte::strtolower($string); + $expected = 'ħ'; + $this->assertEqual($result, $expected); + + $string = 'Ĩ'; + $result = Multibyte::strtolower($string); + $expected = 'ĩ'; + $this->assertEqual($result, $expected); + + $string = 'Ī'; + $result = Multibyte::strtolower($string); + $expected = 'ī'; + $this->assertEqual($result, $expected); + + $string = 'Ĭ'; + $result = Multibyte::strtolower($string); + $expected = 'ĭ'; + $this->assertEqual($result, $expected); + + $string = 'Į'; + $result = Multibyte::strtolower($string); + $expected = 'į'; + $this->assertEqual($result, $expected); + + $string = 'IJ'; + $result = Multibyte::strtolower($string); + $expected = 'ij'; + $this->assertEqual($result, $expected); + + $string = 'Ĵ'; + $result = Multibyte::strtolower($string); + $expected = 'ĵ'; + $this->assertEqual($result, $expected); + + $string = 'Ķ'; + $result = Multibyte::strtolower($string); + $expected = 'ķ'; + $this->assertEqual($result, $expected); + + $string = 'Ĺ'; + $result = Multibyte::strtolower($string); + $expected = 'ĺ'; + $this->assertEqual($result, $expected); + + $string = 'Ļ'; + $result = Multibyte::strtolower($string); + $expected = 'ļ'; + $this->assertEqual($result, $expected); + + $string = 'Ľ'; + $result = Multibyte::strtolower($string); + $expected = 'ľ'; + $this->assertEqual($result, $expected); + + $string = 'Ŀ'; + $result = Multibyte::strtolower($string); + $expected = 'ŀ'; + $this->assertEqual($result, $expected); + + $string = 'Ł'; + $result = Multibyte::strtolower($string); + $expected = 'ł'; + $this->assertEqual($result, $expected); + + $string = 'Ń'; + $result = Multibyte::strtolower($string); + $expected = 'ń'; + $this->assertEqual($result, $expected); + + $string = 'Ņ'; + $result = Multibyte::strtolower($string); + $expected = 'ņ'; + $this->assertEqual($result, $expected); + + $string = 'Ň'; + $result = Multibyte::strtolower($string); + $expected = 'ň'; + $this->assertEqual($result, $expected); + + $string = 'Ŋ'; + $result = Multibyte::strtolower($string); + $expected = 'ŋ'; + $this->assertEqual($result, $expected); + + $string = 'Ō'; + $result = Multibyte::strtolower($string); + $expected = 'ō'; + $this->assertEqual($result, $expected); + + $string = 'Ŏ'; + $result = Multibyte::strtolower($string); + $expected = 'ŏ'; + $this->assertEqual($result, $expected); + + $string = 'Ő'; + $result = Multibyte::strtolower($string); + $expected = 'ő'; + $this->assertEqual($result, $expected); + + $string = 'Œ'; + $result = Multibyte::strtolower($string); + $expected = 'œ'; + $this->assertEqual($result, $expected); + + $string = 'Ŕ'; + $result = Multibyte::strtolower($string); + $expected = 'ŕ'; + $this->assertEqual($result, $expected); + + $string = 'Ŗ'; + $result = Multibyte::strtolower($string); + $expected = 'ŗ'; + $this->assertEqual($result, $expected); + + $string = 'Ř'; + $result = Multibyte::strtolower($string); + $expected = 'ř'; + $this->assertEqual($result, $expected); + + $string = 'Ś'; + $result = Multibyte::strtolower($string); + $expected = 'ś'; + $this->assertEqual($result, $expected); + + $string = 'Ŝ'; + $result = Multibyte::strtolower($string); + $expected = 'ŝ'; + $this->assertEqual($result, $expected); + + $string = 'Ş'; + $result = Multibyte::strtolower($string); + $expected = 'ş'; + $this->assertEqual($result, $expected); + + $string = 'Š'; + $result = Multibyte::strtolower($string); + $expected = 'š'; + $this->assertEqual($result, $expected); + + $string = 'Ţ'; + $result = Multibyte::strtolower($string); + $expected = 'ţ'; + $this->assertEqual($result, $expected); + + $string = 'Ť'; + $result = Multibyte::strtolower($string); + $expected = 'ť'; + $this->assertEqual($result, $expected); + + $string = 'Ŧ'; + $result = Multibyte::strtolower($string); + $expected = 'ŧ'; + $this->assertEqual($result, $expected); + + $string = 'Ũ'; + $result = Multibyte::strtolower($string); + $expected = 'ũ'; + $this->assertEqual($result, $expected); + + $string = 'Ū'; + $result = Multibyte::strtolower($string); + $expected = 'ū'; + $this->assertEqual($result, $expected); + + $string = 'Ŭ'; + $result = Multibyte::strtolower($string); + $expected = 'ŭ'; + $this->assertEqual($result, $expected); + + $string = 'Ů'; + $result = Multibyte::strtolower($string); + $expected = 'ů'; + $this->assertEqual($result, $expected); + + $string = 'Ű'; + $result = Multibyte::strtolower($string); + $expected = 'ű'; + $this->assertEqual($result, $expected); + + $string = 'Ų'; + $result = Multibyte::strtolower($string); + $expected = 'ų'; + $this->assertEqual($result, $expected); + + $string = 'Ŵ'; + $result = Multibyte::strtolower($string); + $expected = 'ŵ'; + $this->assertEqual($result, $expected); + + $string = 'Ŷ'; + $result = Multibyte::strtolower($string); + $expected = 'ŷ'; + $this->assertEqual($result, $expected); + + $string = 'Ź'; + $result = Multibyte::strtolower($string); + $expected = 'ź'; + $this->assertEqual($result, $expected); + + $string = 'Ż'; + $result = Multibyte::strtolower($string); + $expected = 'ż'; + $this->assertEqual($result, $expected); + + $string = 'Ž'; + $result = Multibyte::strtolower($string); + $expected = 'ž'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $result = Multibyte::strtolower($string); + $expected = 'āăąćĉċčďđēĕėęěĝğġģĥħĩīĭįijĵķĺļľŀłńņňŋōŏőœŕŗřśŝşšţťŧũūŭůűųŵŷźżž'; + $this->assertEqual($result, $expected); + + $string = 'ĤĒĹĻŎ, ŴŐŘĻĎ!'; + $result = Multibyte::strtolower($string); + $expected = 'ĥēĺļŏ, ŵőřļď!'; + $this->assertEqual($result, $expected); + + $string = 'ĥēĺļŏ, ŵőřļď!'; + $result = Multibyte::strtolower($string); + $expected = 'ĥēĺļŏ, ŵőřļď!'; + $this->assertEqual($result, $expected); + + $string = 'ἈΙ'; + $result = Multibyte::strtolower($string); + $expected = 'ἀι'; + $this->assertEqual($result, $expected); + } + + function testUsingMbStrtoupper() { + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $result = mb_strtoupper($string); + $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@'; + $result = mb_strtoupper($string); + $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@'; + $this->assertEqual($result, $expected); + + $string = 'à'; + $result = mb_strtoupper($string); + $expected = 'À'; + $this->assertEqual($result, $expected); + + $string = 'á'; + $result = mb_strtoupper($string); + $expected = 'Á'; + $this->assertEqual($result, $expected); + + $string = 'â'; + $result = mb_strtoupper($string); + $expected = 'Â'; + $this->assertEqual($result, $expected); + + $string = 'ã'; + $result = mb_strtoupper($string); + $expected = 'Ã'; + $this->assertEqual($result, $expected); + + $string = 'ä'; + $result = mb_strtoupper($string); + $expected = 'Ä'; + $this->assertEqual($result, $expected); + + $string = 'å'; + $result = mb_strtoupper($string); + $expected = 'Å'; + $this->assertEqual($result, $expected); + + $string = 'æ'; + $result = mb_strtoupper($string); + $expected = 'Æ'; + $this->assertEqual($result, $expected); + + $string = 'ç'; + $result = mb_strtoupper($string); + $expected = 'Ç'; + $this->assertEqual($result, $expected); + + $string = 'è'; + $result = mb_strtoupper($string); + $expected = 'È'; + $this->assertEqual($result, $expected); + + $string = 'é'; + $result = mb_strtoupper($string); + $expected = 'É'; + $this->assertEqual($result, $expected); + + $string = 'ê'; + $result = mb_strtoupper($string); + $expected = 'Ê'; + $this->assertEqual($result, $expected); + + $string = 'ë'; + $result = mb_strtoupper($string); + $expected = 'Ë'; + $this->assertEqual($result, $expected); + + $string = 'ì'; + $result = mb_strtoupper($string); + $expected = 'Ì'; + $this->assertEqual($result, $expected); + + $string = 'í'; + $result = mb_strtoupper($string); + $expected = 'Í'; + $this->assertEqual($result, $expected); + + $string = 'î'; + $result = mb_strtoupper($string); + $expected = 'Î'; + $this->assertEqual($result, $expected); + + $string = 'ï'; + $result = mb_strtoupper($string); + $expected = 'Ï'; + $this->assertEqual($result, $expected); + + $string = 'ð'; + $result = mb_strtoupper($string); + $expected = 'Ð'; + $this->assertEqual($result, $expected); + + $string = 'ñ'; + $result = mb_strtoupper($string); + $expected = 'Ñ'; + $this->assertEqual($result, $expected); + + $string = 'ò'; + $result = mb_strtoupper($string); + $expected = 'Ò'; + $this->assertEqual($result, $expected); + + $string = 'ó'; + $result = mb_strtoupper($string); + $expected = 'Ó'; + $this->assertEqual($result, $expected); + + $string = 'ô'; + $result = mb_strtoupper($string); + $expected = 'Ô'; + $this->assertEqual($result, $expected); + + $string = 'õ'; + $result = mb_strtoupper($string); + $expected = 'Õ'; + $this->assertEqual($result, $expected); + + $string = 'ö'; + $result = mb_strtoupper($string); + $expected = 'Ö'; + $this->assertEqual($result, $expected); + + $string = 'ø'; + $result = mb_strtoupper($string); + $expected = 'Ø'; + $this->assertEqual($result, $expected); + + $string = 'ù'; + $result = mb_strtoupper($string); + $expected = 'Ù'; + $this->assertEqual($result, $expected); + + $string = 'ú'; + $result = mb_strtoupper($string); + $expected = 'Ú'; + $this->assertEqual($result, $expected); + + $string = 'û'; + $result = mb_strtoupper($string); + $expected = 'Û'; + $this->assertEqual($result, $expected); + + $string = 'ü'; + $result = mb_strtoupper($string); + $expected = 'Ü'; + $this->assertEqual($result, $expected); + + $string = 'ý'; + $result = mb_strtoupper($string); + $expected = 'Ý'; + $this->assertEqual($result, $expected); + + $string = 'þ'; + $result = mb_strtoupper($string); + $expected = 'Þ'; + $this->assertEqual($result, $expected); + + $string = 'àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ'; + $result = mb_strtoupper($string); + $expected = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $this->assertEqual($result, $expected); + + $string = 'ā'; + $result = mb_strtoupper($string); + $expected = 'Ā'; + $this->assertEqual($result, $expected); + + $string = 'ă'; + $result = mb_strtoupper($string); + $expected = 'Ă'; + $this->assertEqual($result, $expected); + + $string = 'ą'; + $result = mb_strtoupper($string); + $expected = 'Ą'; + $this->assertEqual($result, $expected); + + $string = 'ć'; + $result = mb_strtoupper($string); + $expected = 'Ć'; + $this->assertEqual($result, $expected); + + $string = 'ĉ'; + $result = mb_strtoupper($string); + $expected = 'Ĉ'; + $this->assertEqual($result, $expected); + + $string = 'ċ'; + $result = mb_strtoupper($string); + $expected = 'Ċ'; + $this->assertEqual($result, $expected); + + $string = 'č'; + $result = mb_strtoupper($string); + $expected = 'Č'; + $this->assertEqual($result, $expected); + + $string = 'ď'; + $result = mb_strtoupper($string); + $expected = 'Ď'; + $this->assertEqual($result, $expected); + + $string = 'đ'; + $result = mb_strtoupper($string); + $expected = 'Đ'; + $this->assertEqual($result, $expected); + + $string = 'ē'; + $result = mb_strtoupper($string); + $expected = 'Ē'; + $this->assertEqual($result, $expected); + + $string = 'ĕ'; + $result = mb_strtoupper($string); + $expected = 'Ĕ'; + $this->assertEqual($result, $expected); + + $string = 'ė'; + $result = mb_strtoupper($string); + $expected = 'Ė'; + $this->assertEqual($result, $expected); + + $string = 'ę'; + $result = mb_strtoupper($string); + $expected = 'Ę'; + $this->assertEqual($result, $expected); + + $string = 'ě'; + $result = mb_strtoupper($string); + $expected = 'Ě'; + $this->assertEqual($result, $expected); + + $string = 'ĝ'; + $result = mb_strtoupper($string); + $expected = 'Ĝ'; + $this->assertEqual($result, $expected); + + $string = 'ğ'; + $result = mb_strtoupper($string); + $expected = 'Ğ'; + $this->assertEqual($result, $expected); + + $string = 'ġ'; + $result = mb_strtoupper($string); + $expected = 'Ġ'; + $this->assertEqual($result, $expected); + + $string = 'ģ'; + $result = mb_strtoupper($string); + $expected = 'Ģ'; + $this->assertEqual($result, $expected); + + $string = 'ĥ'; + $result = mb_strtoupper($string); + $expected = 'Ĥ'; + $this->assertEqual($result, $expected); + + $string = 'ħ'; + $result = mb_strtoupper($string); + $expected = 'Ħ'; + $this->assertEqual($result, $expected); + + $string = 'ĩ'; + $result = mb_strtoupper($string); + $expected = 'Ĩ'; + $this->assertEqual($result, $expected); + + $string = 'ī'; + $result = mb_strtoupper($string); + $expected = 'Ī'; + $this->assertEqual($result, $expected); + + $string = 'ĭ'; + $result = mb_strtoupper($string); + $expected = 'Ĭ'; + $this->assertEqual($result, $expected); + + $string = 'į'; + $result = mb_strtoupper($string); + $expected = 'Į'; + $this->assertEqual($result, $expected); + + $string = 'ij'; + $result = mb_strtoupper($string); + $expected = 'IJ'; + $this->assertEqual($result, $expected); + + $string = 'ĵ'; + $result = mb_strtoupper($string); + $expected = 'Ĵ'; + $this->assertEqual($result, $expected); + + $string = 'ķ'; + $result = mb_strtoupper($string); + $expected = 'Ķ'; + $this->assertEqual($result, $expected); + + $string = 'ĺ'; + $result = mb_strtoupper($string); + $expected = 'Ĺ'; + $this->assertEqual($result, $expected); + + $string = 'ļ'; + $result = mb_strtoupper($string); + $expected = 'Ļ'; + $this->assertEqual($result, $expected); + + $string = 'ľ'; + $result = mb_strtoupper($string); + $expected = 'Ľ'; + $this->assertEqual($result, $expected); + + $string = 'ŀ'; + $result = mb_strtoupper($string); + $expected = 'Ŀ'; + $this->assertEqual($result, $expected); + + $string = 'ł'; + $result = mb_strtoupper($string); + $expected = 'Ł'; + $this->assertEqual($result, $expected); + + $string = 'ń'; + $result = mb_strtoupper($string); + $expected = 'Ń'; + $this->assertEqual($result, $expected); + + $string = 'ņ'; + $result = mb_strtoupper($string); + $expected = 'Ņ'; + $this->assertEqual($result, $expected); + + $string = 'ň'; + $result = mb_strtoupper($string); + $expected = 'Ň'; + $this->assertEqual($result, $expected); + + $string = 'ŋ'; + $result = mb_strtoupper($string); + $expected = 'Ŋ'; + $this->assertEqual($result, $expected); + + $string = 'ō'; + $result = mb_strtoupper($string); + $expected = 'Ō'; + $this->assertEqual($result, $expected); + + $string = 'ŏ'; + $result = mb_strtoupper($string); + $expected = 'Ŏ'; + $this->assertEqual($result, $expected); + + $string = 'ő'; + $result = mb_strtoupper($string); + $expected = 'Ő'; + $this->assertEqual($result, $expected); + + $string = 'œ'; + $result = mb_strtoupper($string); + $expected = 'Œ'; + $this->assertEqual($result, $expected); + + $string = 'ŕ'; + $result = mb_strtoupper($string); + $expected = 'Ŕ'; + $this->assertEqual($result, $expected); + + $string = 'ŗ'; + $result = mb_strtoupper($string); + $expected = 'Ŗ'; + $this->assertEqual($result, $expected); + + $string = 'ř'; + $result = mb_strtoupper($string); + $expected = 'Ř'; + $this->assertEqual($result, $expected); + + $string = 'ś'; + $result = mb_strtoupper($string); + $expected = 'Ś'; + $this->assertEqual($result, $expected); + + $string = 'ŝ'; + $result = mb_strtoupper($string); + $expected = 'Ŝ'; + $this->assertEqual($result, $expected); + + $string = 'ş'; + $result = mb_strtoupper($string); + $expected = 'Ş'; + $this->assertEqual($result, $expected); + + $string = 'š'; + $result = mb_strtoupper($string); + $expected = 'Š'; + $this->assertEqual($result, $expected); + + $string = 'ţ'; + $result = mb_strtoupper($string); + $expected = 'Ţ'; + $this->assertEqual($result, $expected); + + $string = 'ť'; + $result = mb_strtoupper($string); + $expected = 'Ť'; + $this->assertEqual($result, $expected); + + $string = 'ŧ'; + $result = mb_strtoupper($string); + $expected = 'Ŧ'; + $this->assertEqual($result, $expected); + + $string = 'ũ'; + $result = mb_strtoupper($string); + $expected = 'Ũ'; + $this->assertEqual($result, $expected); + + $string = 'ū'; + $result = mb_strtoupper($string); + $expected = 'Ū'; + $this->assertEqual($result, $expected); + + $string = 'ŭ'; + $result = mb_strtoupper($string); + $expected = 'Ŭ'; + $this->assertEqual($result, $expected); + + $string = 'ů'; + $result = mb_strtoupper($string); + $expected = 'Ů'; + $this->assertEqual($result, $expected); + + $string = 'ű'; + $result = mb_strtoupper($string); + $expected = 'Ű'; + $this->assertEqual($result, $expected); + + $string = 'ų'; + $result = mb_strtoupper($string); + $expected = 'Ų'; + $this->assertEqual($result, $expected); + + $string = 'ŵ'; + $result = mb_strtoupper($string); + $expected = 'Ŵ'; + $this->assertEqual($result, $expected); + + $string = 'ŷ'; + $result = mb_strtoupper($string); + $expected = 'Ŷ'; + $this->assertEqual($result, $expected); + + $string = 'ź'; + $result = mb_strtoupper($string); + $expected = 'Ź'; + $this->assertEqual($result, $expected); + + $string = 'ż'; + $result = mb_strtoupper($string); + $expected = 'Ż'; + $this->assertEqual($result, $expected); + + $string = 'ž'; + $result = mb_strtoupper($string); + $expected = 'Ž'; + $this->assertEqual($result, $expected); + + $string = 'āăąćĉċčďđēĕėęěĝğġģĥħĩīĭįijĵķĺļľŀłńņňŋōŏőœŕŗřśŝşšţťŧũūŭůűųŵŷźżž'; + $result = mb_strtoupper($string); + $expected = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $result = mb_strtoupper($string); + $expected = 'ĤĒĹĻŎ, ŴŐŘĻĎ!'; + $this->assertEqual($result, $expected); + + $string = 'ἀι'; + $result = mb_strtoupper($string); + $expected = 'ἈΙ'; + $this->assertEqual($result, $expected); + } + + function testMultibyteStrtoupper() { + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $result = Multibyte::strtoupper($string); + $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@'; + $result = Multibyte::strtoupper($string); + $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@'; + $this->assertEqual($result, $expected); + + $string = 'à'; + $result = Multibyte::strtoupper($string); + $expected = 'À'; + $this->assertEqual($result, $expected); + + $string = 'á'; + $result = Multibyte::strtoupper($string); + $expected = 'Á'; + $this->assertEqual($result, $expected); + + $string = 'â'; + $result = Multibyte::strtoupper($string); + $expected = 'Â'; + $this->assertEqual($result, $expected); + + $string = 'ã'; + $result = Multibyte::strtoupper($string); + $expected = 'Ã'; + $this->assertEqual($result, $expected); + + $string = 'ä'; + $result = Multibyte::strtoupper($string); + $expected = 'Ä'; + $this->assertEqual($result, $expected); + + $string = 'å'; + $result = Multibyte::strtoupper($string); + $expected = 'Å'; + $this->assertEqual($result, $expected); + + $string = 'æ'; + $result = Multibyte::strtoupper($string); + $expected = 'Æ'; + $this->assertEqual($result, $expected); + + $string = 'ç'; + $result = Multibyte::strtoupper($string); + $expected = 'Ç'; + $this->assertEqual($result, $expected); + + $string = 'è'; + $result = Multibyte::strtoupper($string); + $expected = 'È'; + $this->assertEqual($result, $expected); + + $string = 'é'; + $result = Multibyte::strtoupper($string); + $expected = 'É'; + $this->assertEqual($result, $expected); + + $string = 'ê'; + $result = Multibyte::strtoupper($string); + $expected = 'Ê'; + $this->assertEqual($result, $expected); + + $string = 'ë'; + $result = Multibyte::strtoupper($string); + $expected = 'Ë'; + $this->assertEqual($result, $expected); + + $string = 'ì'; + $result = Multibyte::strtoupper($string); + $expected = 'Ì'; + $this->assertEqual($result, $expected); + + $string = 'í'; + $result = Multibyte::strtoupper($string); + $expected = 'Í'; + $this->assertEqual($result, $expected); + + $string = 'î'; + $result = Multibyte::strtoupper($string); + $expected = 'Î'; + $this->assertEqual($result, $expected); + + $string = 'ï'; + $result = Multibyte::strtoupper($string); + $expected = 'Ï'; + $this->assertEqual($result, $expected); + + $string = 'ð'; + $result = Multibyte::strtoupper($string); + $expected = 'Ð'; + $this->assertEqual($result, $expected); + + $string = 'ñ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ñ'; + $this->assertEqual($result, $expected); + + $string = 'ò'; + $result = Multibyte::strtoupper($string); + $expected = 'Ò'; + $this->assertEqual($result, $expected); + + $string = 'ó'; + $result = Multibyte::strtoupper($string); + $expected = 'Ó'; + $this->assertEqual($result, $expected); + + $string = 'ô'; + $result = Multibyte::strtoupper($string); + $expected = 'Ô'; + $this->assertEqual($result, $expected); + + $string = 'õ'; + $result = Multibyte::strtoupper($string); + $expected = 'Õ'; + $this->assertEqual($result, $expected); + + $string = 'ö'; + $result = Multibyte::strtoupper($string); + $expected = 'Ö'; + $this->assertEqual($result, $expected); + + $string = 'ø'; + $result = Multibyte::strtoupper($string); + $expected = 'Ø'; + $this->assertEqual($result, $expected); + + $string = 'ù'; + $result = Multibyte::strtoupper($string); + $expected = 'Ù'; + $this->assertEqual($result, $expected); + + $string = 'ú'; + $result = Multibyte::strtoupper($string); + $expected = 'Ú'; + $this->assertEqual($result, $expected); + + $string = 'û'; + $result = Multibyte::strtoupper($string); + $expected = 'Û'; + $this->assertEqual($result, $expected); + + $string = 'ü'; + $result = Multibyte::strtoupper($string); + $expected = 'Ü'; + $this->assertEqual($result, $expected); + + $string = 'ý'; + $result = Multibyte::strtoupper($string); + $expected = 'Ý'; + $this->assertEqual($result, $expected); + + $string = 'þ'; + $result = Multibyte::strtoupper($string); + $expected = 'Þ'; + $this->assertEqual($result, $expected); + + $string = 'àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ'; + $result = Multibyte::strtoupper($string); + $expected = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $this->assertEqual($result, $expected); + + $string = 'ā'; + $result = Multibyte::strtoupper($string); + $expected = 'Ā'; + $this->assertEqual($result, $expected); + + $string = 'ă'; + $result = Multibyte::strtoupper($string); + $expected = 'Ă'; + $this->assertEqual($result, $expected); + + $string = 'ą'; + $result = Multibyte::strtoupper($string); + $expected = 'Ą'; + $this->assertEqual($result, $expected); + + $string = 'ć'; + $result = Multibyte::strtoupper($string); + $expected = 'Ć'; + $this->assertEqual($result, $expected); + + $string = 'ĉ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ĉ'; + $this->assertEqual($result, $expected); + + $string = 'ċ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ċ'; + $this->assertEqual($result, $expected); + + $string = 'č'; + $result = Multibyte::strtoupper($string); + $expected = 'Č'; + $this->assertEqual($result, $expected); + + $string = 'ď'; + $result = Multibyte::strtoupper($string); + $expected = 'Ď'; + $this->assertEqual($result, $expected); + + $string = 'đ'; + $result = Multibyte::strtoupper($string); + $expected = 'Đ'; + $this->assertEqual($result, $expected); + + $string = 'ē'; + $result = Multibyte::strtoupper($string); + $expected = 'Ē'; + $this->assertEqual($result, $expected); + + $string = 'ĕ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ĕ'; + $this->assertEqual($result, $expected); + + $string = 'ė'; + $result = Multibyte::strtoupper($string); + $expected = 'Ė'; + $this->assertEqual($result, $expected); + + $string = 'ę'; + $result = Multibyte::strtoupper($string); + $expected = 'Ę'; + $this->assertEqual($result, $expected); + + $string = 'ě'; + $result = Multibyte::strtoupper($string); + $expected = 'Ě'; + $this->assertEqual($result, $expected); + + $string = 'ĝ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ĝ'; + $this->assertEqual($result, $expected); + + $string = 'ğ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ğ'; + $this->assertEqual($result, $expected); + + $string = 'ġ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ġ'; + $this->assertEqual($result, $expected); + + $string = 'ģ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ģ'; + $this->assertEqual($result, $expected); + + $string = 'ĥ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ĥ'; + $this->assertEqual($result, $expected); + + $string = 'ħ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ħ'; + $this->assertEqual($result, $expected); + + $string = 'ĩ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ĩ'; + $this->assertEqual($result, $expected); + + $string = 'ī'; + $result = Multibyte::strtoupper($string); + $expected = 'Ī'; + $this->assertEqual($result, $expected); + + $string = 'ĭ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ĭ'; + $this->assertEqual($result, $expected); + + $string = 'į'; + $result = Multibyte::strtoupper($string); + $expected = 'Į'; + $this->assertEqual($result, $expected); + + $string = 'ij'; + $result = Multibyte::strtoupper($string); + $expected = 'IJ'; + $this->assertEqual($result, $expected); + + $string = 'ĵ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ĵ'; + $this->assertEqual($result, $expected); + + $string = 'ķ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ķ'; + $this->assertEqual($result, $expected); + + $string = 'ĺ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ĺ'; + $this->assertEqual($result, $expected); + + $string = 'ļ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ļ'; + $this->assertEqual($result, $expected); + + $string = 'ľ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ľ'; + $this->assertEqual($result, $expected); + + $string = 'ŀ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ŀ'; + $this->assertEqual($result, $expected); + + $string = 'ł'; + $result = Multibyte::strtoupper($string); + $expected = 'Ł'; + $this->assertEqual($result, $expected); + + $string = 'ń'; + $result = Multibyte::strtoupper($string); + $expected = 'Ń'; + $this->assertEqual($result, $expected); + + $string = 'ņ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ņ'; + $this->assertEqual($result, $expected); + + $string = 'ň'; + $result = Multibyte::strtoupper($string); + $expected = 'Ň'; + $this->assertEqual($result, $expected); + + $string = 'ŋ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ŋ'; + $this->assertEqual($result, $expected); + + $string = 'ō'; + $result = Multibyte::strtoupper($string); + $expected = 'Ō'; + $this->assertEqual($result, $expected); + + $string = 'ŏ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ŏ'; + $this->assertEqual($result, $expected); + + $string = 'ő'; + $result = Multibyte::strtoupper($string); + $expected = 'Ő'; + $this->assertEqual($result, $expected); + + $string = 'œ'; + $result = Multibyte::strtoupper($string); + $expected = 'Œ'; + $this->assertEqual($result, $expected); + + $string = 'ŕ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ŕ'; + $this->assertEqual($result, $expected); + + $string = 'ŗ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ŗ'; + $this->assertEqual($result, $expected); + + $string = 'ř'; + $result = Multibyte::strtoupper($string); + $expected = 'Ř'; + $this->assertEqual($result, $expected); + + $string = 'ś'; + $result = Multibyte::strtoupper($string); + $expected = 'Ś'; + $this->assertEqual($result, $expected); + + $string = 'ŝ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ŝ'; + $this->assertEqual($result, $expected); + + $string = 'ş'; + $result = Multibyte::strtoupper($string); + $expected = 'Ş'; + $this->assertEqual($result, $expected); + + $string = 'š'; + $result = Multibyte::strtoupper($string); + $expected = 'Š'; + $this->assertEqual($result, $expected); + + $string = 'ţ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ţ'; + $this->assertEqual($result, $expected); + + $string = 'ť'; + $result = Multibyte::strtoupper($string); + $expected = 'Ť'; + $this->assertEqual($result, $expected); + + $string = 'ŧ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ŧ'; + $this->assertEqual($result, $expected); + + $string = 'ũ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ũ'; + $this->assertEqual($result, $expected); + + $string = 'ū'; + $result = Multibyte::strtoupper($string); + $expected = 'Ū'; + $this->assertEqual($result, $expected); + + $string = 'ŭ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ŭ'; + $this->assertEqual($result, $expected); + + $string = 'ů'; + $result = Multibyte::strtoupper($string); + $expected = 'Ů'; + $this->assertEqual($result, $expected); + + $string = 'ű'; + $result = Multibyte::strtoupper($string); + $expected = 'Ű'; + $this->assertEqual($result, $expected); + + $string = 'ų'; + $result = Multibyte::strtoupper($string); + $expected = 'Ų'; + $this->assertEqual($result, $expected); + + $string = 'ŵ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ŵ'; + $this->assertEqual($result, $expected); + + $string = 'ŷ'; + $result = Multibyte::strtoupper($string); + $expected = 'Ŷ'; + $this->assertEqual($result, $expected); + + $string = 'ź'; + $result = Multibyte::strtoupper($string); + $expected = 'Ź'; + $this->assertEqual($result, $expected); + + $string = 'ż'; + $result = Multibyte::strtoupper($string); + $expected = 'Ż'; + $this->assertEqual($result, $expected); + + $string = 'ž'; + $result = Multibyte::strtoupper($string); + $expected = 'Ž'; + $this->assertEqual($result, $expected); + + $string = 'āăąćĉċčďđēĕėęěĝğġģĥħĩīĭįijĵķĺļľŀłńņňŋōŏőœŕŗřśŝşšţťŧũūŭůűųŵŷźżž'; + $result = Multibyte::strtoupper($string); + $expected = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $result = Multibyte::strtoupper($string); + $expected = 'ĤĒĹĻŎ, ŴŐŘĻĎ!'; + $this->assertEqual($result, $expected); + + $string = 'ἀι'; + $result = mb_strtoupper($string); + $expected = 'ἈΙ'; + $this->assertEqual($result, $expected); + + $string = 'ἀι'; + $result = Multibyte::strtoupper($string); + $expected = 'ἈΙ'; + $this->assertEqual($result, $expected); + } + + function testUsingMbSubstrCount() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = mb_substr_count($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = 'ABCDEFGHIJKLMNOPQFRSFTUVWXYZ0F12345F6789'; + $find = 'F'; + $result = mb_substr_count($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÅÊËÌÍÎÏÐÑÒÓÔÅÕÖØÅÙÚÛÅÜÝÞ'; + $find = 'Å'; + $result = mb_substr_count($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÙÚÂÃÄÅÆÇÈÙÚÉÊËÌÍÎÏÐÑÒÓÔÕÖØÅÙÚÛÜÝÞÙÚ'; + $find = 'ÙÚ'; + $result = mb_substr_count($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊÅËÌÍÎÏÐÑÒÓÔÕÅÖØÅÙÚÅÛÜÅÝÞÅ'; + $find = 'Å'; + $result = mb_substr_count($string, $find); + $expected = 7; + $this->assertEqual($result, $expected); + + $string = 'ĊĀĂĄĆĈĊČĎĐĒĔĖĊĘĚĜĞĠĢĤĦĨĪĬĮĊIJĴĶĹĻĽĿŁŃŅŇŊŌĊŎŐŒŔŖŘŚŜŞŠŢĊŤŦŨŪŬŮŰĊŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = mb_substr_count($string, $find); + $expected = 7; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĊĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁĊŃŅĊŇŊŌŎŐŒŔŖĊŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = mb_substr_count($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./012F34567F89:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghiFjklmnopqFrstuvwFxyz{|}~'; + $find = 'F'; + $result = mb_substr_count($string, $find); + $expected = 6; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥µ¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁµÂõÄÅÆǵÈ'; + $find = 'µ'; + $result = mb_substr_count($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôÕÖõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉÕÖĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝÕÖĞğĠġĢģĤĥĦÕÖħĨĩĪīĬ'; + $find = 'ÕÖ'; + $result = mb_substr_count($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōĵĶķĸĹŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšĵĶķĸĹŢţŤťŦŧŨũŪūŬŭŮůŰűŲųĵĶķĸĹŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'ĵĶķĸĹ'; + $result = mb_substr_count($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƸƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJƸNjnjǍǎǏǐǑǒǓƸǔǕǖǗǘǙǚƸǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = mb_substr_count($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƹƠơƢƣƤƥƦƧƨƩƹƪƫƬƭƮƯưƱƲƳƴƹƵƶƷƸƹƺƻƼƽƾƿǀǁǂƹǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'ƹ'; + $result = mb_substr_count($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞʀɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʀʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʀʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʀʻʼ'; + $find = 'ʀ'; + $result = mb_substr_count($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЇЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = mb_substr_count($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСРТУФХЦЧШЩЪЫЬРЭЮЯабРвгдежзийклРмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = mb_substr_count($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСрТУФХЦЧШЩЪЫрЬЭЮЯабвгдежзийклмнопррстуфхцчшщъыь'; + $find = 'р'; + $result = mb_substr_count($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'فنقكلنمنهونىينًٌٍَُ'; + $find = 'ن'; + $result = mb_substr_count($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✿✴✵✶✷✸✿✹✺✻✼✽✾✿❀❁❂❃❄❅❆✿❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = mb_substr_count($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺐⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺐⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⺐⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = mb_substr_count($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽤⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽤⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = mb_substr_count($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눺눻눼눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕눺눻눼뉖뉗뉘뉙뉚뉛뉜뉝눺눻눼뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눺눻눼'; + $result = mb_substr_count($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'ﺞﺟﺠﺡﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺞﺟﺠﺡﺆﺇﺞﺟﺠﺡﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞﺟﺠﺡ'; + $result = mb_substr_count($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﻞﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻞﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻞﻸﻹﻺﻞﻻﻼ'; + $find = 'ﻞ'; + $result = mb_substr_count($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'abcdkefghijklmnopqrstuvwxkyz'; + $find = 'k'; + $result = mb_substr_count($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = 'abklmcdefghijklmnopqrstuvklmwxyz'; + $find = 'klm'; + $result = mb_substr_count($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = 'abcdppefghijklmnoppqrstuvwxyz'; + $find = 'ppe'; + $result = mb_substr_count($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = mb_substr_count($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = mb_substr_count($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = mb_substr_count($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ĺļ'; + $result = mb_substr_count($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = mb_substr_count($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'rl'; + $result = mb_substr_count($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = mb_substr_count($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = 'ničiničiini'; + $find = 'n'; + $result = mb_substr_count($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = mb_substr_count($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = 'moćimoćimoćmćioći'; + $find = 'ći'; + $result = mb_substr_count($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = mb_substr_count($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = mb_substr_count($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = mb_substr_count($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'H'; + $result = mb_substr_count($string, $find); + $expected = false; + $this->assertEqual($result, $expected); + } + + function testMultibyteSubstrCount() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $find = 'F'; + $result = Multibyte::substrCount($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = 'ABCDEFGHIJKLMNOPQFRSFTUVWXYZ0F12345F6789'; + $find = 'F'; + $result = Multibyte::substrCount($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÅÊËÌÍÎÏÐÑÒÓÔÅÕÖØÅÙÚÛÅÜÝÞ'; + $find = 'Å'; + $result = Multibyte::substrCount($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÙÚÂÃÄÅÆÇÈÙÚÉÊËÌÍÎÏÐÑÒÓÔÕÖØÅÙÚÛÜÝÞÙÚ'; + $find = 'ÙÚ'; + $result = Multibyte::substrCount($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊÅËÌÍÎÏÐÑÒÓÔÕÅÖØÅÙÚÅÛÜÅÝÞÅ'; + $find = 'Å'; + $result = Multibyte::substrCount($string, $find); + $expected = 7; + $this->assertEqual($result, $expected); + + $string = 'ĊĀĂĄĆĈĊČĎĐĒĔĖĊĘĚĜĞĠĢĤĦĨĪĬĮĊIJĴĶĹĻĽĿŁŃŅŇŊŌĊŎŐŒŔŖŘŚŜŞŠŢĊŤŦŨŪŬŮŰĊŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = Multibyte::substrCount($string, $find); + $expected = 7; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĊĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁĊŃŅĊŇŊŌŎŐŒŔŖĊŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = Multibyte::substrCount($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./012F34567F89:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghiFjklmnopqFrstuvwFxyz{|}~'; + $find = 'F'; + $result = Multibyte::substrCount($string, $find); + $expected = 6; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥µ¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁµÂõÄÅÆǵÈ'; + $find = 'µ'; + $result = Multibyte::substrCount($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôÕÖõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉÕÖĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝÕÖĞğĠġĢģĤĥĦÕÖħĨĩĪīĬ'; + $find = 'ÕÖ'; + $result = Multibyte::substrCount($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōĵĶķĸĹŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšĵĶķĸĹŢţŤťŦŧŨũŪūŬŭŮůŰűŲųĵĶķĸĹŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $find = 'ĵĶķĸĹ'; + $result = Multibyte::substrCount($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƸƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJƸNjnjǍǎǏǐǑǒǓƸǔǕǖǗǘǙǚƸǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'Ƹ'; + $result = Multibyte::substrCount($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƹƠơƢƣƤƥƦƧƨƩƹƪƫƬƭƮƯưƱƲƳƴƹƵƶƷƸƹƺƻƼƽƾƿǀǁǂƹǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $find = 'ƹ'; + $result = Multibyte::substrCount($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞʀɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʀʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʀʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʀʻʼ'; + $find = 'ʀ'; + $result = Multibyte::substrCount($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЇЎЏАБВГДЕЖЗИЙКЛ'; + $find = 'Ї'; + $result = Multibyte::substrCount($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСРТУФХЦЧШЩЪЫЬРЭЮЯабРвгдежзийклРмнопрстуфхцчшщъыь'; + $find = 'Р'; + $result = Multibyte::substrCount($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСрТУФХЦЧШЩЪЫрЬЭЮЯабвгдежзийклмнопррстуфхцчшщъыь'; + $find = 'р'; + $result = Multibyte::substrCount($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'فنقكلنمنهونىينًٌٍَُ'; + $find = 'ن'; + $result = Multibyte::substrCount($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✿✴✵✶✷✸✿✹✺✻✼✽✾✿❀❁❂❃❄❅❆✿❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $find = '✿'; + $result = Multibyte::substrCount($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺐⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺐⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⺐⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $find = '⺐'; + $result = Multibyte::substrCount($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽤⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽤⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $find = '⽤'; + $result = Multibyte::substrCount($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눺눻눼눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕눺눻눼뉖뉗뉘뉙뉚뉛뉜뉝눺눻눼뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $find = '눺눻눼'; + $result = Multibyte::substrCount($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'ﺞﺟﺠﺡﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺞﺟﺠﺡﺆﺇﺞﺟﺠﺡﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $find = 'ﺞﺟﺠﺡ'; + $result = Multibyte::substrCount($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﻞﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻞﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻞﻸﻹﻺﻞﻻﻼ'; + $find = 'ﻞ'; + $result = Multibyte::substrCount($string, $find); + $expected = 5; + $this->assertEqual($result, $expected); + + $string = 'abcdkefghijklmnopqrstuvwxkyz'; + $find = 'k'; + $result = Multibyte::substrCount($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = 'abklmcdefghijklmnopqrstuvklmwxyz'; + $find = 'klm'; + $result = Multibyte::substrCount($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = 'abcdppefghijklmnoppqrstuvwxyz'; + $find = 'ppe'; + $result = Multibyte::substrCount($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $find = 'ア'; + $result = Multibyte::substrCount($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $find = 'ハ'; + $result = Multibyte::substrCount($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ő'; + $result = Multibyte::substrCount($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'ĺļ'; + $result = Multibyte::substrCount($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'o'; + $result = Multibyte::substrCount($string, $find); + $expected = 2; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $find = 'rl'; + $result = Multibyte::substrCount($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $find = 'n'; + $result = Multibyte::substrCount($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = 'ničiničiini'; + $find = 'n'; + $result = Multibyte::substrCount($string, $find); + $expected = 3; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $find = 'ć'; + $result = Multibyte::substrCount($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = 'moćimoćimoćmćioći'; + $find = 'ći'; + $result = Multibyte::substrCount($string, $find); + $expected = 4; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $find = 'ž'; + $result = Multibyte::substrCount($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $find = '设'; + $result = Multibyte::substrCount($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $find = '周'; + $result = Multibyte::substrCount($string, $find); + $expected = 1; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $find = 'H'; + $result = Multibyte::substrCount($string, $find); + $expected = false; + $this->assertEqual($result, $expected); + } + + function testUsingMbSubstr() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $result = mb_substr($string, 4, 7); + $expected = 'EFGHIJK'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $result = mb_substr($string, 4, 7); + $expected = 'ÄÅÆÇÈÉÊ'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = mb_substr($string, 4, 7); + $expected = 'ĈĊČĎĐĒĔ'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $result = mb_substr($string, 4, 7); + $expected = '%&\'()*+'; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $result = mb_substr($string, 4); + $expected = '¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $result = mb_substr($string, 4, 7); + $expected = 'ÍÎÏÐÑÒÓ'; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $result = mb_substr($string, 4, 7); + $expected = 'ıIJijĴĵĶķ'; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $result = mb_substr($string, 25); + $expected = 'ƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $result = mb_substr($string, 3); + $expected = 'ɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $result = mb_substr($string, 3); + $expected = 'ЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $result = mb_substr($string, 3, 16); + $expected = 'ПРСТУФХЦЧШЩЪЫЬЭЮ'; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $result = mb_substr($string, 3, 6); + $expected = 'لمنهوى'; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $result = mb_substr($string, 6, 14); + $expected = '✶✷✸✹✺✻✼✽✾✿❀❁❂❃'; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $result = mb_substr($string, 8, 13); + $expected = '⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔'; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $result = mb_substr($string, 12, 24); + $expected = '⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨'; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $result = mb_substr($string, 12, 24); + $expected = '눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄'; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $result = mb_substr($string, 12); + $expected = 'ﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $result = mb_substr($string, 24, 12); + $expected = 'ﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔ'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $result = mb_substr($string, 11, 2); + $expected = 'lm'; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $result = mb_substr($string, 7, 11); + $expected = 'ィゥェォャュョッーアイ'; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $result = mb_substr($string, 13, 13); + $expected = 'ニヌネノハヒフヘホマミムメ'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $result = mb_substr($string, 3, 4); + $expected = 'ļŏ, '; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $result = mb_substr($string, 3, 4); + $expected = 'lo, '; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $result = mb_substr($string, 3); + $expected = 'i'; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $result = mb_substr($string, 1); + $expected = 'oći'; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $result = mb_substr($string, 0, 2); + $expected = 'dr'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $result = mb_substr($string, 3, 3); + $expected = '设为首'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $result = mb_substr($string, 0, 1); + $expected = '一'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $result = mb_substr($string, 6); + $expected = false; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $result = mb_substr($string, 0); + $expected = '一二三周永龍'; + $this->assertEqual($result, $expected); + } + + function testMultibyteSubstr() { + $string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; + $result = Multibyte::substr($string, 4, 7); + $expected = 'EFGHIJK'; + $this->assertEqual($result, $expected); + + $string = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; + $result = Multibyte::substr($string, 4, 7); + $expected = 'ÄÅÆÇÈÉÊ'; + $this->assertEqual($result, $expected); + + $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; + $find = 'Ċ'; + $result = Multibyte::substr($string, 4, 7); + $expected = 'ĈĊČĎĐĒĔ'; + $this->assertEqual($result, $expected); + + $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; + $result = Multibyte::substr($string, 4, 7); + $expected = '%&\'()*+'; + $this->assertEqual($result, $expected); + + $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $result = Multibyte::substr($string, 4); + $expected = '¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; + $this->assertEqual($result, $expected); + + $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; + $result = Multibyte::substr($string, 4, 7); + $expected = 'ÍÎÏÐÑÒÓ'; + $this->assertEqual($result, $expected); + + $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; + $result = Multibyte::substr($string, 4, 7); + $expected = 'ıIJijĴĵĶķ'; + $this->assertEqual($result, $expected); + + $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $result = Multibyte::substr($string, 25); + $expected = 'ƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; + $this->assertEqual($result, $expected); + + $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $result = Multibyte::substr($string, 3); + $expected = 'ɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; + $this->assertEqual($result, $expected); + + $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $result = Multibyte::substr($string, 3); + $expected = 'ЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; + $this->assertEqual($result, $expected); + + $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; + $result = Multibyte::substr($string, 3, 16); + $expected = 'ПРСТУФХЦЧШЩЪЫЬЭЮ'; + $this->assertEqual($result, $expected); + + $string = 'فقكلمنهوىيًٌٍَُ'; + $result = Multibyte::substr($string, 3, 6); + $expected = 'لمنهوى'; + $this->assertEqual($result, $expected); + + $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; + $result = Multibyte::substr($string, 6, 14); + $expected = '✶✷✸✹✺✻✼✽✾✿❀❁❂❃'; + $this->assertEqual($result, $expected); + + $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; + $result = Multibyte::substr($string, 8, 13); + $expected = '⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔'; + $this->assertEqual($result, $expected); + + $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; + $result = Multibyte::substr($string, 12, 24); + $expected = '⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨'; + $this->assertEqual($result, $expected); + + $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; + $result = Multibyte::substr($string, 12, 24); + $expected = '눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄'; + $this->assertEqual($result, $expected); + + $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $result = Multibyte::substr($string, 12); + $expected = 'ﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; + $this->assertEqual($result, $expected); + + $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; + $result = Multibyte::substr($string, 24, 12); + $expected = 'ﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔ'; + $this->assertEqual($result, $expected); + + $string = 'abcdefghijklmnopqrstuvwxyz'; + $result = Multibyte::substr($string, 11, 2); + $expected = 'lm'; + $this->assertEqual($result, $expected); + + $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; + $result = Multibyte::substr($string, 7, 11); + $expected = 'ィゥェォャュョッーアイ'; + $this->assertEqual($result, $expected); + + $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; + $result = Multibyte::substr($string, 13, 13); + $expected = 'ニヌネノハヒフヘホマミムメ'; + $this->assertEqual($result, $expected); + + $string = 'Ĥēĺļŏ, Ŵőřļď!'; + $result = Multibyte::substr($string, 3, 4); + $expected = 'ļŏ, '; + $this->assertEqual($result, $expected); + + $string = 'Hello, World!'; + $result = Multibyte::substr($string, 3, 4); + $expected = 'lo, '; + $this->assertEqual($result, $expected); + + $string = 'čini'; + $result = Multibyte::substr($string, 3); + $expected = 'i'; + $this->assertEqual($result, $expected); + + $string = 'moći'; + $result = Multibyte::substr($string, 1); + $expected = 'oći'; + $this->assertEqual($result, $expected); + + $string = 'državni'; + $result = Multibyte::substr($string, 0, 2); + $expected = 'dr'; + $this->assertEqual($result, $expected); + + $string = '把百度设为首页'; + $result = Multibyte::substr($string, 3, 3); + $expected = '设为首'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $result = Multibyte::substr($string, 0, 1); + $expected = '一'; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $result = Multibyte::substr($string, 6); + $expected = false; + $this->assertEqual($result, $expected); + + $string = '一二三周永龍'; + $result = Multibyte::substr($string, 0); + $expected = '一二三周永龍'; + $this->assertEqual($result, $expected); + } +} +?> \ No newline at end of file