PHP本机函数escapeshellarg在我的机器上转义重音字符
$stringWithAccentedChar = 'Hello à è World';
echo escapeshellarg($stringWithAccentedChar);
// Output : Hello World
我尝试使用语言环境 US 或 FR、iso-8859-1 或 UTF-8。没变。
我认为这是设置问题,因为我使用的每个在线 php 测试器都不会转义这些字符。
如何防止删除重音字符?
PHP本机函数escapeshellarg在我的机器上转义重音字符
$stringWithAccentedChar = 'Hello à è World';
echo escapeshellarg($stringWithAccentedChar);
// Output : Hello World
我尝试使用语言环境 US 或 FR、iso-8859-1 或 UTF-8。没变。
我认为这是设置问题,因为我使用的每个在线 php 测试器都不会转义这些字符。
如何防止删除重音字符?
当 escapeshellarg() 从 UTF-8 字符串中剥离我的非 ASCII 字符时,添加以下内容可以解决问题:
<?php
setlocale(LC_CTYPE, "en_US.UTF-8");
?>
来源:https ://www.php.net/manual/en/function.escapeshellarg.php#99213