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

Breadcrumb

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

function Iconv::utf8ToUtf8

1 call to Iconv::utf8ToUtf8()
Iconv::iconv in vendor/symfony/polyfill-iconv/Iconv.php

File

vendor/symfony/polyfill-iconv/Iconv.php, line 599

Class

Iconv
iconv implementation in pure PHP, UTF-8 centric.

Namespace

Symfony\Polyfill\Iconv

Code

private static function utf8ToUtf8($str, $ignore) {
    $ulenMask = self::$ulenMask;
    $valid = self::$isValidUtf8;
    $u = $str;
    $i = $j = 0;
    $len = \strlen($str);
    while ($i < $len) {
        if ($str[$i] < "\x80") {
            $u[$j++] = $str[$i++];
        }
        else {
            $ulen = $str[$i] & "\xf0";
            $ulen = $ulenMask[$ulen] ?? 1;
            $uchr = substr($str, $i, $ulen);
            if (1 === $ulen || !($valid || preg_match('/^.$/us', $uchr))) {
                if ($ignore) {
                    ++$i;
                    continue;
                }
                trigger_error(self::ERROR_ILLEGAL_CHARACTER);
                return false;
            }
            $i += $ulen;
            $u[$j++] = $uchr[0];
            isset($uchr[1]) && 0 !== ($u[$j++] = $uchr[1]) && isset($uchr[2]) && 0 !== ($u[$j++] = $uchr[2]) && isset($uchr[3]) && 0 !== ($u[$j++] = $uchr[3]);
        }
    }
    return substr($u, 0, $j);
}

API Navigation

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