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

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

			buf = Encoding.ASCII.GetBytes (input);
			n = decoder.Decode (buf, 0, buf.Length, output);
			actual = encoding.GetString (output, 0, n);
			Assert.AreEqual (expected, actual);

			encoding = CharsetUtils.Latin1;

			for (int i = 0; i < qpEncodedPatterns.Length; i++) {
				decoder.Reset ();
				buf = encoding.GetBytes (qpEncodedPatterns[i]);
				n = decoder.Decode (buf, 0, buf.Length, output);
				actual = encoding.GetString (output, 0, n);
				Assert.AreEqual (qpDecodedPatterns[i], actual, "Failed to decode qpEncodedPatterns[{0}]", i);
			}
		}
Пример #2
0
		public void TestQuotedPrintableDecode ()
		{
			const string input = "This is an ordinary text message in which my name (=ED=E5=EC=F9 =EF=E1 =E9=EC=E8=F4=F0)\nis in Hebrew (=FA=E9=F8=E1=F2).";
			const string expected = "This is an ordinary text message in which my name (םולש ןב ילטפנ)\nis in Hebrew (תירבע).";
			var encoding = Encoding.GetEncoding ("iso-8859-8");
			var decoder = new QuotedPrintableDecoder ();
			var output = new byte[4096];

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

			Assert.AreEqual (expected, actual);
		}