Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Component/Utility/Unicode.php \Drupal\Component\Utility\Unicode::check()
  2. 9 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.

1 call to Unicode::check()
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.encoding_translation') != 0) {
    return 'mbstring.encoding_translation';
  }
  return '';
}