我有以下代码:
header('Content-type: text/html; charset=utf-8');
$str = 'áá áá';
echo $str."\n";
echo mb_convert_case($str, MB_CASE_TITLE)."\n";
echo bin2hex($str)."\n";
echo bin2hex(mb_convert_case($str, MB_CASE_TITLE))."\n";
使用 PHP 5.2.2,我得到以下输出:
áá áá
áá áá
c3a1c3a120c3a1c3a1
c3a1c3a120c3a1c3a1
使用 PHP 5.4.3,我得到了这个:
áá áá
á� á�
c3a1c3a120c3a1c3a1
c3a1e3a120c3a1e3a1
在这两种情况下,我的预期输出都是:
áá áá
Áá Áá
c3a1c3a120c3a1c3a1
c381c3a120c381c3a1
所以我有两个问题:
- 为什么 á 不被转换为 Á?
- 为什么 PHP 5.4 会破坏我的字符串?