public void TestCrossingWritePositionExample () { // http://msdn.microsoft.com/en-us/library/ee158471(v=exchg.80).aspx var compressedRtfData = new byte[] { // header 0x1a, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x4c, 0x5a, 0x46, 0x75, 0xe2, 0xd4, 0x4b, 0x51, // data 0x41, 0x00, 0x04, 0x20, 0x57, 0x58, 0x59, 0x5a, 0x0d, 0x6e, 0x7d, 0x01, 0x0e, 0xb0 }; var expected = "{\\rtf1 WXYZWXYZWXYZWXYZWXYZ}"; var converter = new RtfCompressedToRtf (); int outputLength, outputIndex; var decompressed = converter.Flush (compressedRtfData, 0, compressedRtfData.Length, out outputIndex, out outputLength); var text = Encoding.UTF8.GetString (decompressed, outputIndex, outputLength); Assert.AreEqual (expected, text, "Decompressed RTF data does not match."); Assert.IsTrue (converter.IsValidCrc32, "Invalid CRC32 checksum."); }
public void TestSimpleCompressedRtfExample () { // http://msdn.microsoft.com/en-us/library/ee217938(v=exchg.80).aspx var compressedRtfData = new byte[] { // header 0x2d, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x4c, 0x5a, 0x46, 0x75, 0xf1, 0xc5, 0xc7, 0xa7, // data 0x03, 0x00, 0x0a, 0x00, 0x72, 0x63, 0x70, 0x67, 0x31, 0x32, 0x35, 0x42, 0x32, 0x0a, 0xf3, 0x20, 0x68, 0x65, 0x6c, 0x09, 0x00, 0x20, 0x62, 0x77, 0x05, 0xb0, 0x6c, 0x64, 0x7d, 0x0a, 0x80, 0x0f, 0xa0 }; var expected = "{\\rtf1\\ansi\\ansicpg1252\\pard hello world}\r\n"; var converter = new RtfCompressedToRtf (); int outputLength, outputIndex; var decompressed = converter.Flush (compressedRtfData, 0, compressedRtfData.Length, out outputIndex, out outputLength); var text = Encoding.UTF8.GetString (decompressed, outputIndex, outputLength); Assert.AreEqual (expected, text, "Decompressed RTF data does not match."); Assert.IsTrue (converter.IsValidCrc32, "Invalid CRC32 checksum."); }