public void DeUnicodeTest() { string str = string.Empty; string expected = string.Empty; string actual; actual = Encode.DeUnicode(str); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
private MessageValue parse(string text) { text = text.Replace("{", ""); text = text.Replace("]", ""); text = text.Replace("[", ""); text = text.Replace("}", ""); text = text.Replace("\"", ""); //text = text.Replace("]", ""); string[] array = text.Split(','); string item = string.Empty; MessageValue value = new MessageValue(); for (int i = 0; i < array.Length; i++) { item = array[i]; string[] a = item.Split(':'); if (a.Length > 1) { switch (a[0]) { case "result": if (a.Length > 2) { value.PollType = a[2]; } break; case "value": if (a.Length > 2) { value.MsgID = long.Parse(a[2]); } break; case "from_uin": value.FromUin = long.Parse(a[1]); break; case "msg_id": value.MsgID = long.Parse(a[1]); break; case "msg_id2": value.MsgID2 = int.Parse(a[1]); break; case "msg_type": value.MsgType = int.Parse(a[1]); break; case "reply_ip": value.ReplyIP = int.Parse(a[1]); break; case "time": value.Time = int.Parse(a[1]); break; case "to_uin": value.ToUin = long.Parse(a[1]); break; case "color": value.FontColor = GetColor(a[1]); break; case "name": value.Name = Encode.DeUnicode(a[1]); break; case "size": value.FontSize = int.Parse(a[1]); break; case "style": value.FontStyle = string.Format("{0}{1}{2}", a[1], array[i + 1], array[i + 2]); i = i + 2; break; default: break; } } else { //Debug.WriteLine(item); if (item.IndexOf("\\u") > -1) { value.MsgContent = Encode.DeUnicode(item); value.MsgContent = value.MsgContent.Replace("r", "\r\n"); Debug.WriteLine(value.MsgContent); } else { value.MsgContent = item; } } } return(value); }