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

Breadcrumb

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

function UnicodeString::normalize

Overrides AbstractUnicodeString::normalize

File

vendor/symfony/string/UnicodeString.php, line 201

Class

UnicodeString
Represents a string of Unicode grapheme clusters encoded as UTF-8.

Namespace

Symfony\Component\String

Code

public function normalize(int $form = self::NFC) : static {
    $str = clone $this;
    if (\in_array($form, [
        self::NFC,
        self::NFKC,
    ], true)) {
        normalizer_is_normalized($str->string, $form) ?: ($str->string = normalizer_normalize($str->string, $form));
    }
    elseif (!\in_array($form, [
        self::NFD,
        self::NFKD,
    ], true)) {
        throw new InvalidArgumentException('Unsupported normalization form.');
    }
    elseif (!normalizer_is_normalized($str->string, $form)) {
        $str->string = normalizer_normalize($str->string, $form);
        $str->ignoreCase = null;
    }
    return $str;
}
RSS feed
Powered by Drupal