[Original] strings encoded with XMLHTTP binarywrite and post gb2312

Source: Internet
Author: User
/**//*
Author: A niu (NIU kunliang) QQ: 273352165 MSN: niukl@hotmail.com

Disclaimer: free of charge. Please keep this information
If you have any questions, please tell me!
*/
  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 " ) ' Create Stream Object
Ms. Type =   2 ' Text
Ms. charset = Charset ' Sets the stream object encoding method to charset.
Ms. Open
Ms. writetext Str ' Write STR into Stream Object

Ms. Position =   0 ' Set the starting position of the stream object to 0 to set the charset attribute.
Ms. Type =   1 ' Binary

Vout = Ms. Read (Ms. Size) ' Stream pulling
Ms. Close ' Close Stream Object
Set MS =   Nothing
Str2bytes = Vout
End Function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.