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

Breadcrumb

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

function Mbstring::html_encoding_callback

File

vendor/symfony/polyfill-mbstring/Mbstring.php, line 912

Class

Mbstring
Partial mbstring implementation in PHP, iconv based, UTF-8 centric.

Namespace

Symfony\Polyfill\Mbstring

Code

private static function html_encoding_callback(array $m) {
    $i = 1;
    $entities = '';
    $m = unpack('C*', htmlentities($m[0], \ENT_COMPAT, 'UTF-8'));
    while (isset($m[$i])) {
        if (0x80 > $m[$i]) {
            $entities .= \chr($m[$i++]);
            continue;
        }
        if (0xf0 <= $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;
        }
        else {
            $c = ($m[$i++] - 0xc0 << 6) + $m[$i++] - 0x80;
        }
        $entities .= '&#' . $c . ';';
    }
    return $entities;
}

API Navigation

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