"景先生毕设|www.jxszl.com

C# ASCIIEncoding类代码示例

2023-12-29 17:05编辑: www.jxszl.com景先生毕设
本文整理汇总了C#中ASCIIEncoding类的典型用法代码示例。如果您正苦于以下问题:C#ASCIIEncoding类的具体用法?C#ASCIIEncoding怎么用?C#ASCIIEncoding使用的例子?这里精选的类代码示例或许可以为您提供帮助。 示例1:PostHtmlFromUrl /// ///վUTF-8룬HttpPostҲҪUTF-8 ///HttpUtility.UrlEncode(merId,myEncoding) /// ///ʵַ ///ַ /// publicstaticstringPostHtmlFromUrl(stringurl,stringpostData) { StringsResult=""; try { ASCIIEncodingencoding=newASCIIEncoding(); byte[]data=encoding.GetBytes(postData); HttpWebRequestrequest=(HttpWebRequest)WebRequest.Create(url); request.Method="POST"; request.ContentType="application/x-www-form-urlencoded;charset=UTF-8"; request.ContentLength=postData.Length; Streamstream=request.GetRequestStream(); stream.Write(data,0,data.Length); stream.Close(); HttpWebResponseresponse=(HttpWebResponse)request.GetResponse(); StreamReaderreader=newStreamReader(response.GetResponseStream(),Encoding.UTF8); stringcontent=reader.ReadToEnd(); returncontent; } catch(Exceptione) { sResult="-101"; returnsResult; } }
原文链接:http://www.jxszl.com/biancheng/C/556578.html