Exemplo n.º 1
0
        public void TestQuotedPrintableEncode()
        {
            const string expected = "This is an ordinary text message in which my name (=ED=E5=EC=F9 =EF=E1=\n =E9=EC=E8=F4=F0)\nis in Hebrew (=FA=E9=F8=E1=F2).\n";
            const string input    = "This is an ordinary text message in which my name (םולש ןב ילטפנ)\nis in Hebrew (תירבע).\n";
            var          encoding = Encoding.GetEncoding("iso-8859-8");
            var          encoder  = new QuotedPrintableEncoder();
            var          output   = new byte[4096];

            var buf    = encoding.GetBytes(input);
            int n      = encoder.Flush(buf, 0, buf.Length, output);
            var actual = Encoding.ASCII.GetString(output, 0, n);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        public void TestQuotedPrintableEncodeSpaceUnixLineBreak()
        {
            const string input    = "This line ends with a space \nbefore a line break.";
            const string expected = "This line ends with a space=20\nbefore a line break.";
            var          encoder  = new QuotedPrintableEncoder();
            var          output   = new byte[1024];
            string       actual;

            byte[] buf;
            int    n;

            Assert.AreEqual(ContentEncoding.QuotedPrintable, encoder.Encoding);

            buf    = Encoding.ASCII.GetBytes(input);
            n      = encoder.Flush(buf, 0, buf.Length, output);
            actual = Encoding.ASCII.GetString(output, 0, n);
            Assert.AreEqual(expected, actual);
        }