diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 7422596ba10c2aeae6e125d9ba7133c4a5c25d9c..f994cf0f0e8675b22f68ce4da680b196358d378f 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -1001,7 +1001,7 @@ public static function bootEnvironment($app_root = NULL) { // Set sane locale settings, to ensure consistent string, dates, times and // numbers handling. - setlocale(LC_ALL, 'C'); + setlocale(LC_ALL, 'C.UTF-8', 'C'); // Set appropriate configuration for multi-byte strings. mb_internal_encoding('utf-8'); diff --git a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php index 0ae129a8268e387bcdeddfbf2e29d31038465ad3..ec94d2fc52ef3ffe8ffa52623f5b49bc2cd4d8ef 100644 --- a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php +++ b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php @@ -12,6 +12,8 @@ use Prophecy\Argument; use Symfony\Component\HttpFoundation\Request; +// cspell:ignore äöüßαβγδεζηθικλμνξοσὠ+ /** * Tests DIC compilation to disk. * @@ -295,4 +297,17 @@ public function testResetContainer() { $this->assertSame($request_stack, $container->get('request_stack')); } + /** + * Tests system locale. + */ + public function testLocale(): void { + $utf8_string = 'äöüßαβγδεζηθικλμνξοσὠ'; + // Test environment locale should be UTF-8. + $this->assertSame($utf8_string, escapeshellcmd($utf8_string)); + $request = Request::createFromGlobals(); + $kernel = $this->getTestKernel($request); + // Kernel environment locale should be UTF-8. + $this->assertSame($utf8_string, escapeshellcmd($utf8_string)); + } + } diff --git a/core/tests/bootstrap.php b/core/tests/bootstrap.php index 50bacbe2b007090ee9ba89663ad46133731c2138..05479c1d0e58469714fe7b63e70557555053ed70 100644 --- a/core/tests/bootstrap.php +++ b/core/tests/bootstrap.php @@ -147,7 +147,7 @@ class_alias('\Drupal\Tests\DocumentElement', '\Behat\Mink\Element\DocumentElemen // Set sane locale settings, to ensure consistent string, dates, times and // numbers handling. // @see \Drupal\Core\DrupalKernel::bootEnvironment() -setlocale(LC_ALL, 'C'); +setlocale(LC_ALL, 'C.UTF-8', 'C'); // Set appropriate configuration for multi-byte strings. mb_internal_encoding('utf-8');