Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Mbstring.php

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\Mbstring

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal