コード例 #1
0
 public void TestDecodeUnicode()
 {
     Assert.AreEqual("English or 中文 or \u0061\u0308 or \uD834\uDD60", StringExt.DecodeUnicode("English or 中文 or \u0061\u0308 or \uD834\uDD60"));
     Assert.AreEqual("English or 中文 or \u0061\u0308 or \uD834\uDD60", StringExt.DecodeUnicode("English or 中文 or \u0061\u0308 or \U0001D160"));
     Assert.AreEqual("English or 中文 or \u0061\u0308 or \uD834\uDD60", StringExt.DecodeUnicode("English or 中文 or \\u0061\\u0308 or \\uD834\\uDD60"));
     Assert.AreEqual("\x25 \u0061\u0308 or \uD834\uDD60\\", StringExt.DecodeUnicode("\x25 \\u0061\\u0308 or \\uD834\\uDD60\\"));
     Assert.AreEqual("\x25\\x\x2\x25 \x25\x25 \u0061\u0308 or \uD834\uDD60\\", StringExt.DecodeUnicode("\x25\\x\\x2\\x25 \\x025\\x0025 \\u0061\\u0308 or \\uD834\\uDD60\\"));
     Assert.AreEqual(null, StringExt.DecodeUnicode(null));
     Assert.AreEqual("", StringExt.DecodeUnicode(""));
     Assert.AreEqual("\\", StringExt.DecodeUnicode("\\"));
     Assert.AreEqual("\\\\", StringExt.DecodeUnicode("\\\\"));
     Assert.AreEqual("\\\x1", StringExt.DecodeUnicode("\\\\x1"));
     Assert.AreEqual("\\\\\\", StringExt.DecodeUnicode("\\\\\\"));
     Assert.AreEqual("\\\\\x1", StringExt.DecodeUnicode("\\\\\\x1"));
     Assert.AreEqual("\\ab", StringExt.DecodeUnicode("\\ab"));
     Assert.AreEqual("\\a\\b\x23556", StringExt.DecodeUnicode("\\a\\b\\x23556"));
     Assert.AreEqual("\\a\\b\u23556", StringExt.DecodeUnicode("\\a\\b\\u23556"));
     Assert.AreEqual("\\a\\b\\U23556", StringExt.DecodeUnicode("\\a\\b\\U23556"));
 }