一个编码的乱码问题!求解决。 调用接口 返回的地址为\/apps\/\u6211\u7684\u5b58\u50a8\/1.jpg正常的应该是 ↓/apps/我的存储/1.jpg请问一下 中间的这个\u6211\u7684\u5b58\u50a8 怎么转换成 "我的存储"这几个正常的中文呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string str = @"\/apps\/\u6211\u7684\u5b58\u50a8\/1.jpg"; str = Regex.Replace(str, @"\\u([\w]{2})([\w]{2})", a => { byte[] bts = new byte[2]; bts[0] = (byte)int.Parse(a.Groups[2].Value, NumberStyles.HexNumber); bts[1] = (byte)int.Parse(a.Groups[1].Value, NumberStyles.HexNumber); return Encoding.Unicode.GetString(bts); }); //\\/apps\\/我的存储\\/1.jpg string str = @"/apps/\u6211\u7684\u5b58\u50a8/1.jpg"; str = Regex.Replace(str, @"\\u([\w]{2})([\w]{2})", a => { byte[] bts = new byte[2]; bts[0] = (byte)int.Parse(a.Groups[2].Value, NumberStyles.HexNumber); bts[1] = (byte)int.Parse(a.Groups[1].Value, NumberStyles.HexNumber); return Encoding.Unicode.GetString(bts); }); // /apps/我的存储/1.jpg public class UnicodeHelper { public static string Decode(string str) { Regex regex = new Regex(@"(?i)\\[uU]([0-9a-f]{4})"); return regex.Replace(str, delegate(Match m) { char ch = (char)Convert.ToInt32(m.Groups[1].Value, 0x10); return ch.ToString(); }); } } 调用。string str = @"/apps/\u6211\u7684\u5b58\u50a8/1.jpg";string str2=UnicodeHelper.Decode(str); WinForm中关于TreeView的问题,急求 怎么用多线程调用带参数的方法? c#中, 返回代表十六进制数值的 String 的函数 是哪个 C#如何判断一个读取的文件是否为ACCESS文件 .NET程序员(C# + SQL Server) 3名 输出到word表格(表格为N行1列)换行问题 低级问题?请问怎么把SqlDataReader放进try块中? b/s分页的问题 我想用一个窗体打开一个新的窗体,然后这个窗体隐藏,等新窗体关闭的时候,在显示出来,怎么实现? 在线等,急求各位了。 Java和C#UDP通信问题 C#中把多个DataSet取出的Tables组合在一起
str = Regex.Replace(str, @"\\u([\w]{2})([\w]{2})", a => {
byte[] bts = new byte[2];
bts[0] = (byte)int.Parse(a.Groups[2].Value, NumberStyles.HexNumber);
bts[1] = (byte)int.Parse(a.Groups[1].Value, NumberStyles.HexNumber);
return Encoding.Unicode.GetString(bts);
});
//\\/apps\\/我的存储\\/1.jpg
str = Regex.Replace(str, @"\\u([\w]{2})([\w]{2})", a => {
byte[] bts = new byte[2];
bts[0] = (byte)int.Parse(a.Groups[2].Value, NumberStyles.HexNumber);
bts[1] = (byte)int.Parse(a.Groups[1].Value, NumberStyles.HexNumber);
return Encoding.Unicode.GetString(bts);
});
// /apps/我的存储/1.jpg
public class UnicodeHelper
{
public static string Decode(string str)
{
Regex regex = new Regex(@"(?i)\\[uU]([0-9a-f]{4})");
return regex.Replace(str, delegate(Match m)
{
char ch = (char)Convert.ToInt32(m.Groups[1].Value, 0x10);
return ch.ToString();
});
}
}
string str2=UnicodeHelper.Decode(str);