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

Breadcrumb

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

function Helper::width

Returns the width of a string, using mb_strwidth if it is available. The width is how many characters positions the string will use.

32 calls to Helper::width()
Application::doRenderThrowable in vendor/symfony/console/Application.php
Application::find in vendor/symfony/console/Application.php
Finds a command by name or alias.
ConsoleSectionOutput::getDisplayLength in vendor/symfony/console/Output/ConsoleSectionOutput.php
FormatterHelper::formatBlock in vendor/symfony/console/Helper/FormatterHelper.php
Formats a message as a block of text.
FormatterHelper::truncate in vendor/symfony/console/Helper/FormatterHelper.php
Truncates a message to the given length.

... See full list

File

vendor/symfony/console/Helper/Helper.php, line 40

Class

Helper
Helper is the base class for all helper classes.

Namespace

Symfony\Component\Console\Helper

Code

public static function width(?string $string) : int {
    $string ??= '';
    if (preg_match('//u', $string)) {
        return (new UnicodeString($string))->width(false);
    }
    if (false === ($encoding = mb_detect_encoding($string, null, true))) {
        return \strlen($string);
    }
    return mb_strwidth($string, $encoding);
}

API Navigation

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