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

Breadcrumb

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

function Idn::isValidContextJ

Parameters

string $label:

Return value

bool

1 call to Idn::isValidContextJ()
Idn::validateLabel in vendor/symfony/polyfill-intl-idn/Idn.php

File

vendor/symfony/polyfill-intl-idn/Idn.php, line 227

Class

Idn
@internal

Namespace

Symfony\Polyfill\Intl\Idn

Code

private static function isValidContextJ(array $codePoints, $label) {
    if (!isset(self::$virama)) {
        self::$virama = (require __DIR__ . \DIRECTORY_SEPARATOR . 'Resources' . \DIRECTORY_SEPARATOR . 'unidata' . \DIRECTORY_SEPARATOR . 'virama.php');
    }
    $offset = 0;
    foreach ($codePoints as $i => $codePoint) {
        if (0x200c !== $codePoint && 0x200d !== $codePoint) {
            continue;
        }
        if (!isset($codePoints[$i - 1])) {
            return false;
        }
        // If Canonical_Combining_Class(Before(cp)) .eq. Virama Then True;
        if (isset(self::$virama[$codePoints[$i - 1]])) {
            continue;
        }
        // If RegExpMatch((Joining_Type:{L,D})(Joining_Type:T)*\u200C(Joining_Type:T)*(Joining_Type:{R,D})) Then
        // True;
        // Generated RegExp = ([Joining_Type:{L,D}][Joining_Type:T]*\u200C[Joining_Type:T]*)[Joining_Type:{R,D}]
        if (0x200c === $codePoint && 1 === preg_match(Regex::ZWNJ, $label, $matches, \PREG_OFFSET_CAPTURE, $offset)) {
            $offset += \strlen($matches[1][0]);
            continue;
        }
        return false;
    }
    return true;
}
RSS feed
Powered by Drupal