You are here

public static function Unicode::check in Drupal 9

Same name and namespace in other branches
  1. 8 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 124

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 '';
}