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

Breadcrumb

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

function Xml::isUtf8

1 call to Xml::isUtf8()
Xml::convertToUtf8 in vendor/phpunit/phpunit/src/Util/Xml/Xml.php

File

vendor/phpunit/phpunit/src/Util/Xml/Xml.php, line 55

Class

Xml
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit

Namespace

PHPUnit\Util

Code

private static function isUtf8(string $string) : bool {
    $length = strlen($string);
    for ($i = 0; $i < $length; $i++) {
        if (ord($string[$i]) < 0x80) {
            $n = 0;
        }
        elseif ((ord($string[$i]) & 0xe0) === 0xc0) {
            $n = 1;
        }
        elseif ((ord($string[$i]) & 0xf0) === 0xe0) {
            $n = 2;
        }
        elseif ((ord($string[$i]) & 0xf0) === 0xf0) {
            $n = 3;
        }
        else {
            return false;
        }
        for ($j = 0; $j < $n; $j++) {
            if (++$i === $length || (ord($string[$i]) & 0xc0) !== 0x80) {
                return false;
            }
        }
    }
    return true;
}

API Navigation

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