日期:2014-05-17 浏览次数:20813 次
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();