将字符串转换为微弱代码的问题(在PHP中,使用phlyLabs的punycode字符串转换器)
我正在使用这里的代码:http://phlymail.com/en/downloads/idna/download/并构建了一个这样的函数(来自示例):
function convert_to_punycode($inputstring)
{
$IDN = new idna_convert();
// The input string, if input is not UTF-8 or UCS-4, it must be converted before
$inputstringutf8 = utf8_encode($inputstring);
// Encode it to its punycode presentation
$outputstringpunycode = $IDN->encode($inputstringutf8);
return $outputstringpunycode;
}
但它无法正常工作。
For the input: Россию
It gives: РоÑÑиÑ
Whereas it should give: xn--h1alffa3f
我究竟做错了什么?正在传递的$ inputstring是一个普通的字符串,没有特殊的声明/ etc ...
没有找到相关结果
已邀请:
4 个回复
草票
舞备联
邵酮
肉脓措伪