我试图将域:http://pfeffermühle.com转换为一个正确的旁遮普敦格式的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.comPHP:
echo idn_to_ascii('http://pfeffermühle.com');
RESULT: xn--http://pfeffermhle-06b.com但正确的结果是:http://xn--pfeffermhle-0hb.com
你可以在这里查一下:
http://www.idnconverter.se/http://xn--pfeffermhle-0hb.com
有什么问题吗?
请帮帮忙。
谢谢
发布于 2017-01-17 14:02:16
从字符串中删除“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@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);https://stackoverflow.com/questions/41694813
复制相似问题