public void TestEncodeUnicode() { Assert.AreEqual("English or \\u4E2D\\u6587 or a\\u0308 or \\uD834\\uDD60", StringExt.EncodeUnicode("English or 中文 or \u0061\u0308 or \uD834\uDD60")); Assert.AreEqual("English or \\u4E2D\\u6587 or a\\u0308 or \\uD834\\uDD60", StringExt.EncodeUnicode("English or 中文 or \u0061\u0308 or \U0001D160")); Assert.AreEqual("% a\\u0308 or \\uD834\\uDD60\\", StringExt.EncodeUnicode("\x25 \u0061\u0308 or \uD834\uDD60\\")); Assert.AreEqual(null, StringExt.EncodeUnicode(null)); Assert.AreEqual("", StringExt.EncodeUnicode("")); Assert.AreEqual("\\", StringExt.EncodeUnicode("\\")); Assert.AreEqual("\\\\", StringExt.EncodeUnicode("\\\\")); Assert.AreEqual("\\\\u0001", StringExt.EncodeUnicode("\\\x1")); Assert.AreEqual("\\\\\\", StringExt.EncodeUnicode("\\\\\\")); Assert.AreEqual("\\\\\\u0001", StringExt.EncodeUnicode("\\\\\x1")); Assert.AreEqual("\\ab", StringExt.EncodeUnicode("\\ab")); Assert.AreEqual("\\a\\b\\u23556", StringExt.EncodeUnicode("\\a\\b\x23556")); Assert.AreEqual("\\a\\b\\u23556", StringExt.EncodeUnicode("\\a\\b\u23556")); Assert.AreEqual("\\a\\b\\U23556", StringExt.EncodeUnicode("\\a\\b\\U23556")); }