: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
return iconv_strpos($haystack, $needle, $offset, $encoding);
public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
$encoding = self::getEncoding($encoding);
if ('CP850' === $encoding || 'ASCII' === $encoding) {
return strrpos($haystack, $needle, $offset);
if ($offset != (int) $offset) {
} elseif ($offset = (int) $offset) {
if (0 > $offset += self::mb_strlen($needle)) {
$haystack = self::mb_substr($haystack, 0, $offset, $encoding);
$haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
$pos = iconv_strrpos($haystack, $needle, $encoding);
return false !== $pos ? $offset + $pos : false;
public static function mb_str_split($string, $split_length = 1, $encoding = null)
if (null !== $string && !\is_scalar($string) && !(\is_object($string) && \method_exists($string, '__toString'))) {
trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', E_USER_WARNING);
if (1 > $split_length = (int) $split_length) {
trigger_error('The length of each segment must be greater than zero', E_USER_WARNING);
if (null === $encoding) {
$encoding = mb_internal_encoding();
if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
while (65535 < $split_length) {
$rx .= '.{'.$split_length.'})/us';
return preg_split($rx, $string, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
$length = mb_strlen($string, $encoding);
for ($i = 0; $i < $length; $i += $split_length) {
$result[] = mb_substr($string, $i, $split_length, $encoding);
public static function mb_strtolower($s, $encoding = null)
return self::mb_convert_case($s, MB_CASE_LOWER, $encoding);
public static function mb_strtoupper($s, $encoding = null)
return self::mb_convert_case($s, MB_CASE_UPPER, $encoding);
public static function mb_substitute_character($c = null)
if (0 === strcasecmp($c, 'none')) {
return null !== $c ? false : 'none';
public static function mb_substr($s, $start, $length = null, $encoding = null)
$encoding = self::getEncoding($encoding);
if ('CP850' === $encoding || 'ASCII' === $encoding) {
return (string) substr($s, $start, null === $length ? 2147483647 : $length);
$start = iconv_strlen($s, $encoding) + $start;
$length = iconv_strlen($s, $encoding) + $length - $start;
return (string) iconv_substr($s, $start, $length, $encoding);
public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
$haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
$needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
return self::mb_strpos($haystack, $needle, $offset, $encoding);
public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
$pos = self::mb_stripos($haystack, $needle, 0, $encoding);
return self::getSubpart($pos, $part, $haystack, $encoding);
public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
$encoding = self::getEncoding($encoding);
if ('CP850' === $encoding || 'ASCII' === $encoding) {
$pos = strrpos($haystack, $needle);
$needle = self::mb_substr($needle, 0, 1, $encoding);
$pos = iconv_strrpos($haystack, $needle, $encoding);
return self::getSubpart($pos, $part, $haystack, $encoding);
public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
$needle = self::mb_substr($needle, 0, 1, $encoding);
$pos = self::mb_strripos($haystack, $needle, $encoding);
return self::getSubpart($pos, $part, $haystack, $encoding);
public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
$haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
$needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
return self::mb_strrpos($haystack, $needle, $offset, $encoding);
public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
$pos = strpos($haystack, $needle);
return substr($haystack, 0, $pos);
return substr($haystack, $pos);
public static function mb_get_info($type = 'all')
'internal_encoding' => self::$internalEncoding,
'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)',
'func_overload_list' => 'no overload',
'mail_charset' => 'UTF-8',
'mail_header_encoding' => 'BASE64',
'mail_body_encoding' => 'BASE64',
'encoding_translation' => 'Off',
'language' => self::$language,
'detect_order' => self::$encodingList,
'substitute_character' => 'none',
'strict_detection' => 'Off',
if (isset($info[$type])) {
public static function mb_http_input($type = '')
public static function mb_http_output($encoding = null)
return null !== $encoding ? 'pass' === $encoding : 'pass';
public static function mb_strwidth($s, $encoding = null)
$encoding = self::getEncoding($encoding);
if ('UTF-8' !== $encoding) {
$s = iconv($encoding, 'UTF-8//IGNORE', $s);
$s = preg_replace('/[\x{1100}-\x{115F}\x{2329}\x{232A}\x{2E80}-\x{303E}\x{3040}-\x{A4CF}\x{AC00}-\x{D7A3}\x{F900}-\x{FAFF}\x{FE10}-\x{FE19}\x{FE30}-\x{FE6F}\x{FF00}-\x{FF60}\x{FFE0}-\x{FFE6}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}]/u', '', $s, -1, $wide);
return ($wide << 1) + iconv_strlen($s, 'UTF-8');
public static function mb_substr_count($haystack, $needle, $encoding = null)
return substr_count($haystack, $needle);
public static function mb_output_handler($contents, $status)
public static function mb_chr($code, $encoding = null)
if (0x80 > $code %= 0x200000) {
} elseif (0x800 > $code) {
$s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
} elseif (0x10000 > $code) {
$s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
$s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
$s = mb_convert_encoding($s, $encoding, 'UTF-8');
public static function mb_ord($s, $encoding = null)
if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
$s = mb_convert_encoding($s, 'UTF-8', $encoding);
$code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
return (($code - 0xC0) << 6) + $s[2] - 0x80;
private static function getSubpart($pos, $part, $haystack, $encoding)
return self::mb_substr($haystack, 0, $pos, $encoding);
return self::mb_substr($haystack, $pos, null, $encoding);
private static function html_encoding_callback(array $m)
$m = unpack('C*', htmlentities($m[0], ENT_COMPAT, 'UTF-8'));
$entities .= \chr($m[$i++]);
$c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
} elseif (0xE0 <= $m[$i]) {
$c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
$c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
$entities .= '&#'.$c.';';
private static function title_case(array $s)
return self::mb_convert_case($s[1], MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], MB_CASE_LOWER, 'UTF-8');
private static function getData($file)
if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
private static function getEncoding($encoding)
if (null === $encoding) {
return self::$internalEncoding;
if ('UTF-8' === $encoding) {
$encoding = strtoupper($encoding);
if ('8BIT' === $encoding || 'BINARY' === $encoding) {
if ('UTF8' === $encoding) {