function Unicode::check

Same name in other branches
  1. 8.9.x core/lib/Drupal/Component/Utility/Unicode.php \Drupal\Component\Utility\Unicode::check()
  2. 10 core/lib/Drupal/Component/Utility/Unicode.php \Drupal\Component\Utility\Unicode::check()
  3. 11.x core/lib/Drupal/Component/Utility/Unicode.php \Drupal\Component\Utility\Unicode::check()

Checks for Unicode support in PHP and sets the proper settings if possible.

Because of the need to be able to handle text in various encodings, we do not support mbstring function overloading. HTTP input/output conversion must be disabled for similar reasons.

Return value

string A string identifier of a failed multibyte extension check, if any. Otherwise, an empty string.

2 calls to Unicode::check()
system_requirements in core/modules/system/system.install
Implements hook_requirements().
Unicode::getStatus in core/lib/Drupal/Component/Utility/Unicode.php
Gets the current status of unicode/multibyte support on this environment.

File

core/lib/Drupal/Component/Utility/Unicode.php, line 123

Class

Unicode
Provides Unicode-related conversions and operations.

Namespace

Drupal\Component\Utility

Code

public static function check() {
    // Set appropriate configuration.
    mb_internal_encoding('utf-8');
    mb_language('uni');
    // Check for mbstring extension.
    if (!extension_loaded('mbstring')) {
        return 'mb_strlen';
    }
    // Check mbstring configuration.
    if (ini_get('mbstring.func_overload') != 0) {
        return 'mbstring.func_overload';
    }
    if (ini_get('mbstring.encoding_translation') != 0) {
        return 'mbstring.encoding_translation';
    }
    return '';
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.