Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP idn_to_ascii/VB.net idn.GetAscii()不会生成正确的小代码/idn域_Php_Vb.net_Idn_Punycode - Fatal编程技术网

PHP idn_to_ascii/VB.net idn.GetAscii()不会生成正确的小代码/idn域

PHP idn_to_ascii/VB.net idn.GetAscii()不会生成正确的小代码/idn域,php,vb.net,idn,punycode,Php,Vb.net,Idn,Punycode,我试图转换域: 以Punycode形式连接到正确的IDN域。 我使用了vb.net和php,但两种结果都不正确 VB.net: Dim idn As New System.Globalization.IdnMapping() Dim punyCode As String = idn.GetAscii(http://pfeffermühle.com) RESULT: punyCode= xn--http://pfeffermhle-06b.com PHP: 但正确的结果是: 您可以在这里查看:

我试图转换域: 以Punycode形式连接到正确的IDN域。 我使用了vb.net和php,但两种结果都不正确

VB.net:

Dim idn As New System.Globalization.IdnMapping()
Dim punyCode As String = idn.GetAscii(http://pfeffermühle.com)

RESULT: punyCode= xn--http://pfeffermhle-06b.com
PHP:

但正确的结果是:

您可以在这里查看:

有什么问题

请帮忙

谢谢

从字符串中删除“http://”,它不是域名的一部分,而是使用的协议

VB.NET

Dim idn As New System.Globalization.IdnMapping()
Dim punyCode As String = idn.GetAscii("pfeffermühle.com")

Console.WriteLine(punyCode)
Console.WriteLine("http://" & idn.GetUnicode(punyCode))
结果:

xn--pfeffermhle-0hb.com
http://pfeffermühle.com
PHP来自@memme

$s1 = "hTtps://pfeffermühle.com";;
$s = trim($s1);

if (idn_to_ascii($s) <> $s)
    {
    if (substr(strtolower($s) , 0, 7) === "http://")
        {
        $s = "http://" . idn_to_ascii(substr($s, 7, strlen($s) - 7));
        }
    elseif (substr(strtolower($s) , 0, 8) === "https://")
        {
        $s = "https://" . idn_to_ascii(substr($s, 8, strlen($s) - 8));
        }
    }

echo $s . "<br />" . idn_to_ascii($s1);
$s1=“hTtps://pfefferm"www.ulhle.com",;;
$s=修剪($s1);
if(idn_至ascii($s)$s)
{
if(substr(strtolower($s),0,7)=“http://”)
{
$s=“http://”.idn_to_ascii(substr($s,7,strlen($s)-7));
}
elseif(substr(strtolower($s),0,8)=“https://”)
{
$s=“https://”.idn_to_ascii(substr($s,8,strlen($s)-8));
}
}
echo$s。“
”。idn到ascii($s1);
将您的php添加到答案中,因此答案更完整。对不起,正确答案是:$s1=“”$s=修剪(s1美元);如果(idn_to_ascii($s)$s){if(substr(strtolower($s),0,7)==“http:/”{$s=“http:/”.idn_to_ascii(substr($s,7,strlen($s)-7))}.elseif(substr(strtolower($s),0,8)==“https:/”{$s=“https:/”{$https:=“https:/”。idn to_to_ascii(substr($s($s,8,strlen($s)-8))};
$s1 = "hTtps://pfeffermühle.com";;
$s = trim($s1);

if (idn_to_ascii($s) <> $s)
    {
    if (substr(strtolower($s) , 0, 7) === "http://")
        {
        $s = "http://" . idn_to_ascii(substr($s, 7, strlen($s) - 7));
        }
    elseif (substr(strtolower($s) , 0, 8) === "https://")
        {
        $s = "https://" . idn_to_ascii(substr($s, 8, strlen($s) - 8));
        }
    }

echo $s . "<br />" . idn_to_ascii($s1);