function replaceregex(str) set regex=new regExp regex.pattern="//x(..)//x(..)" regex.IgnoreCase=true regex.global=true matches=regex.replace(str,"%u$2$1") replaceregex=matches end Function
Function getHTTPPage(Path) t = GetBody(Path) getHTTPPage = BytesToBstr(t, "GB2312") End Function
Function GetBody(url) On Error Resume Next Set Retrieval = CreateObject("Microsoft.XMLHTTP") With Retrieval .Open "Get", url, False, "", "" .Send GetBody = .ResponseBody End With Set Retrieval = Nothing End Function
Function BytesToBstr(Body, Cset) Dim objstream Set objstream = CreateObject("adodb.stream") objstream.Type = 1 objstream.Mode = 3 objstream.Open objstream.Write Body objstream.Position = 0 objstream.Type = 2 objstream.Charset = Cset BytesToBstr = objstream.ReadText objstream.Close Set objstream = Nothing End Function
Function URLEncoding(vstrIn) strReturn = "" For aaaa = 1 To Len(vstrIn) ThisChr = Mid(vStrIn,aaaa,1) If Abs(Asc(ThisChr)) < &HFF Then strReturn = strReturn & ThisChr Else innerCode = Asc(ThisChr) If innerCode < 0 Then innerCode = innerCode + &H10000 End If Hight8 = (innerCode And &HFF00)/ &HFF Low8 = innerCode And &HFF strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8) End If Next URLEncoding = strReturn End Function
set fso=CreateObject("scripting.filesystemobject") set fileS=fso.opentextfile("a.txt",2,true) fileS.writeline replaceregex(code) 'fileS.writeline body wscript.echo replaceregex(code) files.close set fso=Nothing