更新时间:2023-02-17 18:50:48
您可以先使用iconv
将输入转换为utf-8,然后再将转换应用于ASCII.要检测当前的编码,可以使用mb_detect_encoding
.
You could first convert your input to utf-8 using iconv
and then apply your conversion to ASCII. To detect the current encoding you can use mb_detect_encoding
.
$aUTF8 = iconv(mb_detect_encoding($a, 'UTF-8, ISO-8859-1', true), 'UTF-8', $a);
$bUTF8 = iconv(mb_detect_encoding($b, 'UTF-8, ISO-8859-1', true), 'UTF-8', $b);
$aASCII = iconv("utf-8", "ascii//TRANSLIT", $aUTF8);
$bASCII = iconv("utf-8", "ascii//TRANSLIT", $bUTF8);
请注意,您可能必须将其他编码添加到mb_detect_encoding
的编码列表中.
Please note that you might have to add additional encodings to the encoding list of mb_detect_encoding
.