public void CustomDecoderFallback() { byte[] encoded = { 0x80, 0xA1, 0x83 }; encoder = new EucJpEncoding( new DecoderReplacementFallback("?!"), new EncoderExceptionFallback()); Assert.AreEqual("?!?!?!", encoder.GetString(encoded)); }
public void CustomEncoderFallback() { string decoded = "€\ud801\udc37"; encoder = new EucJpEncoding( new DecoderExceptionFallback(), new EncoderReplacementFallback("?!")); byte[] expected = { 0x3F, 0x21, 0x3F, 0x21, 0x3F, 0x21 }; Assert.AreEqual(expected, encoder.GetBytes(decoded)); }
public void ConstructorSetFallbacks() { encoder = new EucJpEncoding( new DecoderReplacementFallback("@"), new EncoderReplacementFallback("@")); Assert.IsInstanceOf <DecoderReplacementFallback>(encoder.DecoderFallback); Assert.IsInstanceOf <EncoderReplacementFallback>(encoder.EncoderFallback); // We can't override original Encoding baseEncoding = encoder; Assert.IsNotInstanceOf <DecoderReplacementFallback>(baseEncoding.DecoderFallback); Assert.IsNotInstanceOf <EncoderReplacementFallback>(baseEncoding.EncoderFallback); }
public void SetUp() { encoder = new EucJpEncoding(); }