zoukankan      html  css  js  c++  java
  • [原创]用XMLHttp BinaryWrite,Post GB2312编码的字串

          /*
        作者:阿牛(牛昆亮) QQ:273352165 MSN:niukl@hotmail.com
        
        声明:可以免费使用,请您保留此信息
            如果您有什么改过,记得告诉我!
        
    */
           
     
    function PostDataToUrl(strUrl,strContent)
            
    set xmlhttp = CreateObject("MSXML2.XMLhttp")
            xmlhttp.open 
    "POST",strUrl,false
            xmlhttp.setRequestHeader 
    "CONTENT-TYPE","text/xml;charset=gb2312;"
            vout 
    = Str2Bytes(strcontent,"gb2312")
            xmlhttp.setRequestHeader 
    "Content-Length",len(vout)
            xmlhttp.send(vout)
            strxml 
    = xmlhttp.responseText
            
    set xmlhttp = nothing
            PostDataToUrl 
    = strxml
        
    end function
        
        
    Function Str2Bytes(str,charset)
            
    Dim ms,strRet
            
    Set ms = CreateObject("ADODB.Stream")    '建立流对象
            ms.Type = 2             ' Text
            ms.Charset = charset    '设置流对象的编码方式为 charset
            ms.Open                    
            ms.WriteText str            
    '把str写入流对象中
            
            ms.Position 
    = 0         '设置流对象的起始位置是0 以设置Charset属性
            ms.Type = 1              'Binary

            vout 
    = ms.Read(ms.Size)    '取字符流
            ms.close                '关闭流对象
            Set ms = nothing
            Str2Bytes 
    = vout
        
    End Function

    QQ:273352165 evlon#126.com 转载请注明出处。
  • 相关阅读:
    MySQL存储引擎InnoDB与Myisam的六大区别
    PHP+mysql防止SQL注入
    HTTPS 的实现原理
    如何保障 API 接口的安全性?
    使用Merge存储引擎实现MySQL分表
    彻底搞懂Reactor模型和Proactor模型
    REDIS集群脑裂以及解决方案
    linux shell文件合并 去重 分割
    python fnmatch & glob
    sed初理多行合并+sed之G、H、g、h使用+sed n/N使用说明
  • 原文地址:https://www.cnblogs.com/evlon/p/381627.html
Copyright © 2011-2022 走看看