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

Breadcrumb

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

function Iconv::iconv_substr

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

File

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

Class

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

Namespace

Symfony\Polyfill\Iconv

Code

public static function iconv_substr($s, $start, $length = 2147483647, $encoding = null) {
    if (null === $encoding) {
        $encoding = self::$internalEncoding;
    }
    if (0 !== stripos($encoding, 'utf-8')) {
        $encoding = null;
    }
    elseif (false === ($s = self::iconv($encoding, 'utf-8', $s))) {
        return false;
    }
    $s = (string) $s;
    $slen = self::iconv_strlen($s, 'utf-8');
    $start = (int) $start;
    if (0 > $start) {
        $start += $slen;
    }
    if (0 > $start) {
        if (\PHP_VERSION_ID < 80000) {
            return false;
        }
        $start = 0;
    }
    if ($start >= $slen) {
        return \PHP_VERSION_ID >= 80000 ? '' : false;
    }
    $rx = $slen - $start;
    if (0 > $length) {
        $length += $rx;
    }
    if (0 === $length) {
        return '';
    }
    if (0 > $length) {
        return \PHP_VERSION_ID >= 80000 ? '' : false;
    }
    if ($length > $rx) {
        $length = $rx;
    }
    $rx = '/^' . ($start ? self::pregOffset($start) : '') . '(' . self::pregOffset($length) . ')/u';
    $s = preg_match($rx, $s, $s) ? $s[1] : '';
    if (null === $encoding) {
        return $s;
    }
    return self::iconv('utf-8', $encoding, $s);
}

API Navigation

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