if (!is_string($ret) || __strlen($ret) != $resultLength) { return false; }
return $ret; }
/** * Get a substring based on byte limits * * @see __strlen() * * @param string $binary_string The input string * @param int $start * @param int $length * * @internal * @return string The substring */ function __substr($binary_string, $start, $length) { if (function_exists('mb__substr')) { return mb__substr($binary_string, $start, $length, '8bit'); } return substr($binary_string, $start, $length); }
/** * Count the number of bytes in a string * * We cannot simply use strlen() for this, because it might be overwritten by the mbstring extension. * In this case, strlen() will count the number of *characters* based on the internal encoding. A * sequence of bytes might be regarded as a single multibyte character. * * @param string $binary_string The input string * * @internal * @return int The number of bytes */ function __strlen($binary_string) { if (function_exists('mb__strlen')) { return mb__strlen($binary_string, '8bit'); } return strlen($binary_string); }