public static function 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.

5 calls to Unicode::check()
UnicodeTest::setUp in drupal/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php
UnicodeTest::testTruncate in drupal/core/tests/Drupal/Tests/Component/Utility/UnicodeTest.php
Tests Unicode::truncate().
unicode_requirements in drupal/core/includes/unicode.inc
Returns Unicode library status and errors.
_drupal_bootstrap_configuration in drupal/core/includes/bootstrap.inc
Sets up the script environment and loads settings.php.
_drupal_maintenance_theme in drupal/core/includes/theme.maintenance.inc
Sets up the theming system for maintenance page.

File

drupal/core/lib/Drupal/Component/Utility/Unicode.php, line 148
Contains \Drupal\Component\Utility\Unicode.

Class

Unicode
Provides Unicode-related conversions and operations.

Namespace

Drupal\Component\Utility

Code

public static function check() {

  // Check for mbstring extension.
  if (!function_exists('mb_strlen')) {
    static::$status = static::STATUS_SINGLEBYTE;
    return 'mb_strlen';
  }

  // Check mbstring configuration.
  if (ini_get('mbstring.func_overload') != 0) {
    static::$status = static::STATUS_ERROR;
    return 'mbstring.func_overload';
  }
  if (ini_get('mbstring.encoding_translation') != 0) {
    static::$status = static::STATUS_ERROR;
    return 'mbstring.encoding_translation';
  }
  if (ini_get('mbstring.http_input') != 'pass') {
    static::$status = static::STATUS_ERROR;
    return 'mbstring.http_input';
  }
  if (ini_get('mbstring.http_output') != 'pass') {
    static::$status = static::STATUS_ERROR;
    return 'mbstring.http_output';
  }

  // Set appropriate configuration.
  mb_internal_encoding('utf-8');
  mb_language('uni');
  static::$status = static::STATUS_MULTIBYTE;
  return '';
}