首页 » 默认不分类 » 中文域名转码函数

中文域名转码函数

Function punycode(byval strdomain)
	On error resume Next
	Dim cncurl,xmlobj
	CNCURL="http://www.cnnic.net.cn/cgi-bin/conv.cgi?code=puny&name=" & strdomain
	Set xmlobj=CreateObject("WinHttp.WinHttpRequest.5.1")
	xmlobj.setTimeouts 10000, 10000, 10000, 30000  
	xmlobj.open "GET",CNCURL,false
	xmlobj.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
	xmlobj.send
	retCode=xmlobj.ResponseText
	Set xmlobj=Nothing
  	punycode=myinstr(retCode,":\s+([\w\.\-]+)\s*</pre")
end Function
 
function myinstr(byval mystring, byval regstr)
	Dim oReg,matches,match
	Set oReg = New RegExp	
	oReg.Pattern=regstr:oreg.IgnoreCase=True
	Set matches=oReg.execute(mystring)
	For each match in matches
		myinstr=match.subMatches(0)
	Next
	Set oReg=nothing
end function

, , ,

转发到新浪微博 转发到新浪微博

目前这篇文章有27条评论(Rss)

我要评论