日期:2014-05-18 浏览次数:21244 次
string str = "5Y2a5a6i5Zut55So5oi35biQ5oi35r+A5rS76YKu5Lu2"; byte[] bytes = Convert.FromBase64String(str); Console.WriteLine(Encoding.UTF8.GetString(bytes));
------解决方案--------------------
//转成utf-8
string str = "中国科技论文在线-首发论文退稿";
byte[] utf8 = Encoding.UTF8.GetBytes(str);
string s3 = "";
foreach (byte b in utf8)
{
s3 += "=" + string.Format("{0:X2}", b);
}
Response.Write(s3 + "<br />");
//转成汉字
string cd = "=E4=B8=AD=E5=9B=BD=E7=A7=91=E6=8A=80=E8=AE=BA=E6=96=87=E5=9C=A8=E7=BA=BF=2D=E9=A6=96=E5=8F=91=E8=AE=BA=E6=96=87=E9=80=80=E7=A8=BF";
string[] b6 = cd.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
byte[] bs = new byte[b6.Length];
int i = 0;
while (i<b6.Length)
{
bs[i] = (byte)Convert.ToByte(b6[i], 16);
i++;
}
Response.Write(Encoding.GetEncoding("UTF-8").GetString(bs));