function Mbstring::mb_ord
1 call to Mbstring::mb_ord()
- Mbstring::mb_encode_numericentity in vendor/
symfony/ polyfill-mbstring/ Mbstring.php
File
-
vendor/
symfony/ polyfill-mbstring/ Mbstring.php, line 813
Class
- Mbstring
- Partial mbstring implementation in PHP, iconv based, UTF-8 centric.
Namespace
Symfony\Polyfill\MbstringCode
public static function mb_ord($s, $encoding = null) {
if ('UTF-8' !== ($encoding = self::getEncoding($encoding))) {
$s = mb_convert_encoding($s, 'UTF-8', $encoding);
}
if (1 === \strlen($s)) {
return \ord($s);
}
$code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
if (0xf0 <= $code) {
return ($code - 0xf0 << 18) + ($s[2] - 0x80 << 12) + ($s[3] - 0x80 << 6) + $s[4] - 0x80;
}
if (0xe0 <= $code) {
return ($code - 0xe0 << 12) + ($s[2] - 0x80 << 6) + $s[3] - 0x80;
}
if (0xc0 <= $code) {
return ($code - 0xc0 << 6) + $s[2] - 0x80;
}
return $code;
}