在JS里encodeURI过的汉字,在c#里怎么解码
展开全部
1、将十六进制转化为字符;
2、将字符转化为ascll码
public string HexToStr(string mHex) // 返回十六进制代表的字符串
{
mHex =
mHex.Replace(" ", "");
if (mHex.Length <= 0) return "";
byte[] vBytes
= new byte[mHex.Length / 2];
for (int i = 0;
i < mHex.Length; i += 2)
if (!byte.TryParse(mHex.Substring(i, 2), NumberStyles.HexNumber, null, out
vBytes[i / 2]))
vBytes[i / 2] = 0;
return
ASCIIEncoding.Default.GetString(vBytes);
}
2、将字符转化为ascll码
public string HexToStr(string mHex) // 返回十六进制代表的字符串
{
mHex =
mHex.Replace(" ", "");
if (mHex.Length <= 0) return "";
byte[] vBytes
= new byte[mHex.Length / 2];
for (int i = 0;
i < mHex.Length; i += 2)
if (!byte.TryParse(mHex.Substring(i, 2), NumberStyles.HexNumber, null, out
vBytes[i / 2]))
vBytes[i / 2] = 0;
return
ASCIIEncoding.Default.GetString(vBytes);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询