C#中的乱码问题,寻求解答
Whois.cs文件如下:
--------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Net.Sockets;
using System.IO;
namespace tstWhois.LeeCen.Whois
{
class Whois
{
//将要查询的域名
private string _DomainName;
public string DomainName
{
get { return _DomainName; }
set
{
if (value.ToLower().IndexOf("www.") >= 0)
{
_DomainName = value.Substring(4, value.Length - 4);
}
else
{
_DomainName = value;
}
}
}
//将要查询的Whois服务器地址
private string _WhoisServer;
public string WhoisServer
{
get { return _WhoisServer; }
set
{
if (value.EndsWith(".cn"))
{
_WhoisServer = value;
}
else
{
Hashtable table = this.GetWhoisServers();
string domainType = this.GetDomainType();
_WhoisServer = table[domainType.ToString()].ToString();
}
}
}
//默认端口是43
public int Port = 43;
//构造函数
public Whois()
{
this.DomainName = "59.cn";
this.WhoisServer = "whois.cnnic.net.cn";
}
public Whois(string strDomainName)
{
this.DomainName = strDomainName;
this.WhoisServer = "whois.cnnic.net.cn";
}
public Whois(string strDomainName, string strWhoisServer)
{
this.DomainName = strDomainName;
this.WhoisServer = strWhoisServer;
}
//得到默认的Whois服务器信息
public Hashtable GetWhoisServers()
{
Hashtable serTable = new Hashtable();
serTable.Add("cn", "whois.cnnic.net.cn"); //一般cn域名的whois
serTable.Add("com.cn", "whois.cnnic.net.cn");
serTable.Add("org.cn", "whois.cnnic.net.cn");
serTable.Add("net.cn", "whois.cnnic.net.cn");
serTable.Add("info.cn", "whois.cnnic.net.cn");
serTable.Add("biz.cn", "whois.cnnic.net.cn");
serTable.Add("edu.cn", "whois.edu.cn"); //教育网
serTable.Add("com", "whois.internic.net"); //在美国的(开始)
serTable.Add("net", "whois.internic.net"); //
serTable.Add("org", "whois.internic.net"); //
serTable.Add("biz", "whois.internic.net"); //
serTable.Add("info", &quo