重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
//unicode编码转换为中文
创新互联建站是工信部颁发资质IDC服务器商,为用户提供优质的成都西云数据中心服务
public static string UnicodeToGB(string text)
{
System.Text.RegularExpressions.MatchCollection mc = System.Text.RegularExpressions.Regex.Matches(text, "\\\\u([\\w]{4})");
if (mc != null mc.Count 0)
{
foreach (System.Text.RegularExpressions.Match m2 in mc)
{
string v = m2.Value;
string word = v.Substring(2);
byte[] codes = new byte[2];
int code = System.Convert.ToInt32(word.Substring(0, 2), 16);
int code2 = System.Convert.ToInt32(word.Substring(2), 16);
codes[0] = (byte)code2;
codes[1] = (byte)code;
text = text.Replace(v, Encoding.Unicode.GetString(codes));
}
}
else
{
}
return text;
}
给你个C#.net的代码做一下参考,原理都是类似的。
这个用到库的问题(是matlab库)
开头:
#include mex.h/*这个matlab自己的也是必须的*/
库函数(4个参数)//名字忘了太长了
{
//自己的程序;
}
这个问题有点意思,但题主表意不明,确切的说应该分Web端和客户端两种情况。
想来问到这个问题的不应该是开发Web端的,说说客户端的吧:
1、HttpWebRequest.CookieContainer
Cookies通过HttpResponse传给客户端,通过HttpRequest传回服务端,因此你可以
设置Response.Cookies集合的值修改Cookie
1
Response.Cookies("MyCookie")("Data") = myCookie
通过读取Request.Cookies集合的值得到Cookies的值
1
myCookie =Request.Cookies("MyCookie")("Data") ""
2、本人自编的一个函数,放到一个模块里直接调用即可:
Dim myCookie As String
Public Function LoginAnGetCookie(ByRef sUser As String, ByRef sPass As String) As String()
On Error Resume Next
REM 登录网站并获得cookie
Dim url As String = "网站地址"
Dim postData As String = "sUser=" sUser "sPass=" sPass '假设传值的是这样的,实际中可用Fiddler抓取。
Dim wc As System.Net.WebClient = New System.Net.WebClient
Rem wc.Headers.Add("Cookie", myCookie) '可讲第一次获得的Cookie赋值给myCookie,然后在此处传值给网站即可
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
wc.Headers.Add("UserAgent", "Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10)")
Dim sHtml As String = wc.UploadString(url, "POST", postData)
Dim arrAllKeys() As String = wc.ResponseHeaders.AllKeys
Dim sCookies As String = "Set-Cookie"
For i As Integer = 0 To arrAllKeys.Length - 1
If arrAllKeys(i).Equals("Set-Cookie") Then sCookies = wc.ResponseHeaders.Get(i)
Next i
Return New String() {sHtml, sCookies} '返回二维数组,其中LoginAnGetCookie(0)是网页源代码,LoginAnGetCookie(1)是登录后的Cookie
End Function