本文整理汇总了C#中System.Globalization.IdnMapping.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# IdnMapping.GetHashCode方法的具体用法?C# IdnMapping.GetHashCode怎么用?C# IdnMapping.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Globalization.IdnMapping
的用法示例。
在下文中一共展示了IdnMapping.GetHashCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
string email = "johann_doe@bücher.com john_doe@hotmail.com иван@мойдомен.рф";
IdnMapping idn = new IdnMapping();
int start = 0, end = 0;
while (end >= 0) {
start = email.IndexOf("@", end);
end = email.IndexOf(" ", start);
string domain = String.Empty;
try {
string punyCode = String.Empty;
if (start >= 0 && end >= 0) {
domain = email.Substring(start + 1, end - start - 1);
punyCode = idn.GetAscii(email, start + 1, end - start - 1);
}
else {
domain = email.Substring(start + 1);
punyCode = idn.GetAscii(email, start + 1);
}
string name2 = idn.GetUnicode(punyCode);
Console.WriteLine("{0} --> {1} --> {2}", domain, punyCode, name2);
}
catch (ArgumentException) {
Console.WriteLine("{0} is not a valid domain name.", domain);
}
Console.WriteLine();
}
}
}
输出:
bücher.com --> xn--bcher-kva.com --> bücher.com hotmail.com --> hotmail.com --> hotmail.com мойдомен.рф --> xn--d1acklchcc.xn--p1ai --> мойдомен.рф