Complete hash of Chinese pages Script Solutions
Related Tags:
Use XMLHTTP Post / Get html pages of the complete hash of Chinese Script Solutions
E text of the first look at how the form is submitted:
StrA = "submit1 & Submit = = scsdfsd text1";
Var oReq = new ActiveXObject ( "MSXML2.XMLHTTP");
OReq.open ( "POST", "http://ServerName/VDir/TstResult.asp" false);
OReq.setRequestHeader ( "Content-Length" strA.length);
OReq.setRequestHeader ( "CONTENT-TYPE", "application / x-www-form-urlencoded");
OReq.send (strA);
</ ScRIPT>
If the strA = "submit1 & Submit = = scsdfsd text1" replaced by:
StrA = "submit1 & Submit = = Chinese text1";
You will find them in the wrong fundamental Dongdong, ASP in the Request.Form ( "Text1") did not get a fundamental value. I used Request.BinaryRead an HTML Form to the Post wrote of the contents, found the problem - Form submitted to the code, the code is similar to the Chinese characters %??%?? the escape, for example, "Chinese" were coded as follows: Chinese. Oh, I also blame the stupid, people CONTENT-TYPE clearly, clearly written - application/x-www-form- urlencoded, urlencoded This is just like the course. Since it is so, then we know how do the - do their own conversion, the code below:
<SCRIPT Language="VBScript">
Function URLEncoding (vstrIn)
StrReturn = ""
For i = 1 To Len (vstrIn)
ThisChr = Mid (vStrIn, i, 1)
If Abs (Asc (ThisChr)) <& HFF Then
StrReturn = strReturn & ThisChr
Else
InnerCode = Asc (ThisChr)
If innerCode <0 Then
InnerCode = & H10000 innerCode
End If
Hight8 = (innerCode And & HFF00) \ & HFF
InnerCode And Low8 = & HFF
StrReturn strReturn & = "%" & Hex (Hight8) & "%" & Hex (Low8)
End If
Next
URLEncoding = strReturn
End Function
StrA = URLEncoding ( "submit1 & Submit = = Chinese text1")
OReq = CreateObject ( "MSXML2.XMLHTTP")
OReq.open "POST", "http://ServerName/VDir/TstResult.asp" false
OReq.setRequestHeader "Content-Length," Len (strA)
OReq.setRequestHeader "CONTENT-TYPE", "application / x-www-form-urlencoded"
OReq.send strA
</ ScRIPT>
(I here in front of the JavaScript code into the VBScript is not enough to stem the hold of nothing, why see below)
Part II. Correct by the Chinese content
OK, if you end the Form Server writes the contents of the database / document, you see where the Chinese there is no problem, but if you want to look at the Server Response - to the question: If the outcome is not Response XML, XMLHTTP.responseXML course, it would not be Dongdong, then used responseText Well, in the code and the final one:
Alert (oReq.responseText)
俺们look at the result of hard work: P
However, all but the Chinese ..... how all become a box (I was not out to test their own interest, they do not have Post, Get a website containing Chinese can be found.)
The reason is simple: XMLHTTP be assumed Response Response is UTF8 encoding, if Response is XML, it can also, through the encoding to specify encoding, but HTML to do so. (Damn GB2312, once again beat!) So it GB2312-coding the HTML format as UTF8 not Caiweigui wrong!
However Fortunately, there are remedies approach: XMLHTTP the responseBody However, the attribute contains no decoding Resonse - "a raw undecoded bytes as received directly from the server":), the only problem is that the return is a responseBody unsigned an array of bytes, we how to access it, how it converted into BSTR?
That is why I am in the above code into VBScript reasons - VBScript Can do it, but JavaScript Cannot!
Code below:
<SCRIPT Language="VBScript">
Function URLEncoding (vstrIn)
StrReturn = ""
For i = 1 To Len (vstrIn)
ThisChr = Mid (vStrIn, i, 1)
If Abs (Asc (ThisChr)) <& HFF Then
StrReturn = strReturn & ThisChr
Else
InnerCode = Asc (ThisChr)
If innerCode <0 Then
InnerCode = & H10000 innerCode
End If
Hight8 = (innerCode And & HFF00) \ & HFF
InnerCode And Low8 = & HFF
StrReturn strReturn & = "%" & Hex (Hight8) & "%" & Hex (Low8)
End If
Next
URLEncoding = strReturn
End Function
Function bytes2BSTR (vIn)
StrReturn = ""
For i = 1 To LenB (vIn)
ThisCharCode = AscB (MidB (vIn, i, 1))
If ThisCharCode <& H80 Then
StrReturn = strReturn & Chr (ThisCharCode)
Else
NextCharCode = AscB (MidB (vIn, i 1,1))
StrReturn = strReturn & Chr (CLng (ThisCharCode) * & H100 CInt (NextCharCode))
I = i 1
End If
Next
Bytes2BSTR = strReturn
End Function
StrA = URLEncoding ( "submit1 & Submit = = Chinese text1")
OReq = CreateObject ( "MSXML2.XMLHTTP")
OReq.open "POST", "http://ServerName/VDir/TstResult.asp" false
OReq.setRequestHeader "Content-Length," Len (strA)
OReq.setRequestHeader "CONTENT-TYPE", "application / x-www-form-urlencoded"
OReq.send strA
Alert bytes2BSTR (oReq.responseBody)
</ ScRIPT>
Ah is not very simple, and use this to try? All OK!
- CSS intensive manual (5)
- CSS development manual
- CSS intensive manual (3)
- Css intensive manual (1)
- Css Manual (2) [Text
- Css Manual (7) Classification Classification
- CSS Development Manual [Author: nilxin]
- CSS intensive manual (2)
- Css Manual (c) Font font
- CSS intensive manual 4
- Chinese typesetting experience CSS
- CSS Manual (4) Border Border
- CSS quick Manual 1
- CSS intensive manual (4)
- All commonly used language reference manual for manual HTML | CSS manuals | JScript Manual | VbScript Manual | ASP Manual | PHP Manual | SQL manual | Site effects | ADO Manual
- Css Manual (1) Background Background
- CSS intensive manual 2
- CSS intensive manual (7)
- CSS quick Manual 3
- Css Manual (6) List List
Alexa Web site showed the world rankings code

Alexa head of the world rankings has not unfamiliar to many, and this year it will be a very formidable speculation, many sites either advertising or publicity pull to Alexa world rankings will be based. Therefore, my station (http://bbs.51free.com.ru) as an example, the code wi...
Entrepreneurs: the world WAP personal website created by the legendary

In the Internet era where thoughts can be exhumed as long as gold. Currently has 6 million mobile phone users "WAP world" website is the case, in the three years after the successful operation of the present become one of the largest interactive wireless Internet porta...
Javascript in the deep and shallow copy copy the realization of

Javascript, as in the assignment and is the same as in Java, are passed by reference. That is to say, to an assignment to as a variable, then the variables are still at the original is like address. How to do it that the answer is cloning. What is a "clone&qu...
16 Dreamweaver use of fast techniques

1, flexibility in the use of style Familiar with the Internet web page design know, call Style many ways, we can click the right mouse button to call options Custon Style Style standards, the status bar can be an element in the list, click right to call Style. Alth...
Common XHTML validation error

Common XHTML validation error Original: http://www.blackwidows.org.uk/resources/tutorials/xhtml/common-errors.html Without coding and symbols ("&") Example: <a Href="foo.cgi?chapter=1§ion=2"> ...<...