//unicode編碼轉(zhuǎn)換為中文
創(chuàng)新互聯(lián)建站是工信部頒發(fā)資質(zhì)IDC服務(wù)器商,為用戶提供優(yōu)質(zhì)的成都西云數(shù)據(jù)中心服務(wù)
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;
}
給你個(gè)C#.net的代碼做一下參考,原理都是類似的。
這個(gè)用到庫(kù)的問題(是matlab庫(kù))
開頭:
#include mex.h/*這個(gè)matlab自己的也是必須的*/
庫(kù)函數(shù)(4個(gè)參數(shù))//名字忘了太長(zhǎng)了
{
//自己的程序;
}
這個(gè)問題有點(diǎn)意思,但題主表意不明,確切的說應(yīng)該分Web端和客戶端兩種情況。
想來(lái)問到這個(gè)問題的不應(yīng)該是開發(fā)Web端的,說說客戶端的吧:
1、HttpWebRequest.CookieContainer
Cookies通過HttpResponse傳給客戶端,通過HttpRequest傳回服務(wù)端,因此你可以
設(shè)置Response.Cookies集合的值修改Cookie
1
Response.Cookies("MyCookie")("Data") = myCookie
通過讀取Request.Cookies集合的值得到Cookies的值
1
myCookie =Request.Cookies("MyCookie")("Data") ""
2、本人自編的一個(gè)函數(shù),放到一個(gè)模塊里直接調(diào)用即可:
Dim myCookie As String
Public Function LoginAnGetCookie(ByRef sUser As String, ByRef sPass As String) As String()
On Error Resume Next
REM 登錄網(wǎng)站并獲得cookie
Dim url As String = "網(wǎng)站地址"
Dim postData As String = "sUser=" sUser "sPass=" sPass '假設(shè)傳值的是這樣的,實(shí)際中可用Fiddler抓取。
Dim wc As System.Net.WebClient = New System.Net.WebClient
Rem wc.Headers.Add("Cookie", myCookie) '可講第一次獲得的Cookie賦值給myCookie,然后在此處傳值給網(wǎng)站即可
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} '返回二維數(shù)組,其中LoginAnGetCookie(0)是網(wǎng)頁(yè)源代碼,LoginAnGetCookie(1)是登錄后的Cookie
End Function