私はここからコードを使用しています: 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 は、特別な宣言などのない通常の文字列です...