Skip to content

Commit c97ff7a

Browse files
committed
Add a configuration check for encoding detection
1 parent d917261 commit c97ff7a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

webapp/src/Service/CheckConfigService.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public function runAll(): array
5252
'php_version' => $this->checkPhpVersion(),
5353
'php_extensions' => $this->checkPhpExtensions(),
5454
'php_settings' => $this->checkPhpSettings(),
55+
'mbstring_settings' => $this->checkMbstringSettings(),
5556
'mysql_settings' => $this->checkMysqlSettings(),
5657
];
5758

@@ -197,6 +198,23 @@ public function checkPhpSettings(): ConfigCheckItem
197198
);
198199
}
199200

201+
public function checkMbstringSettings(): ConfigCheckItem
202+
{
203+
$this->stopwatch->start(__FUNCTION__);
204+
205+
$desc = "\nFor submission source code displaying, the detect order should at least contain all expected submission encodings:\n";
206+
$desc .= sprintf(" - `mbstring.detect_order` should at least contain `UTF-8` (now set to `%s`).\n", implode(', ', mb_detect_order()));
207+
$desc .= sprintf(" - Supported encodings: `%s`.\n", implode(', ', mb_list_encodings()));
208+
$result = in_array('UTF-8', mb_detect_order()) ? 'O' : 'W';
209+
210+
$this->stopwatch->stop(__FUNCTION__);
211+
return new ConfigCheckItem(
212+
caption: 'PHP multibyte string settings',
213+
result: $result,
214+
desc: $desc
215+
);
216+
}
217+
200218
public function checkMysqlSettings(): ConfigCheckItem
201219
{
202220
$this->stopwatch->start(__FUNCTION__);

0 commit comments

Comments
 (0)