public void EncodingDoesNotChangeValidUtf8Symbols() { Encoding encoding = new EscapeOutRangeEncoding("utf-8"); byte[] validBuffer = { 0xE3, 0x81, 0x82, 0xE3, 0xE3, 0x81, 0x82 }; string output = encoding.GetString(validBuffer); Assert.AreEqual(output.Length, encoding.GetCharCount(validBuffer)); Assert.Less(output.Length, encoding.GetMaxCharCount(3)); Assert.AreEqual("あ[@!!E3]あ", output); }
public void EncodingReplaceInvalidUtf8Symbols() { Encoding encoding = new EscapeOutRangeEncoding("utf-8"); byte[] invalidBuffer = { 0xE2, 0x81, 0xE3, 0xE4 }; string output = encoding.GetString(invalidBuffer); Assert.AreEqual(output.Length, encoding.GetCharCount(invalidBuffer)); Assert.Less(output.Length, encoding.GetMaxCharCount(4)); Assert.AreEqual("[@!!E281][@!!E3][@!!E4]", output); }