예제 #1
0
 public virtual void TestShouldEncodeAndDecodeISO8859_1Text()
 {
     EncodedText encodedText = new EncodedText(EncodedText.TEXT_ENCODING_ISO_8859_1, TEST_STRING);
     Assert.AreEqual(EncodedText.CHARSET_ISO_8859_1, encodedText.GetCharacterSet());
     Assert.AreEqual(TEST_STRING, encodedText.ToString());
     EncodedText encodedText2;
     byte[] bytes;
     // no bom & no terminator
     bytes = encodedText.ToBytes();
     Assert.AreEqual(TEST_STRING_HEX_ISO8859_1, TestHelper.BytesToHexString(bytes));
     encodedText2 = new EncodedText(EncodedText.TEXT_ENCODING_ISO_8859_1, bytes);
     Assert.AreEqual(encodedText, encodedText2);
     // bom & no terminator
     bytes = encodedText.ToBytes(true);
     Assert.AreEqual(TEST_STRING_HEX_ISO8859_1, TestHelper.BytesToHexString(bytes));
     encodedText2 = new EncodedText(EncodedText.TEXT_ENCODING_ISO_8859_1, bytes);
     Assert.AreEqual(encodedText, encodedText2);
     // no bom & terminator
     bytes = encodedText.ToBytes(false, true);
     Assert.AreEqual(TEST_STRING_HEX_ISO8859_1 + " 00", TestHelper.BytesToHexString(bytes));
     encodedText2 = new EncodedText(EncodedText.TEXT_ENCODING_ISO_8859_1, bytes);
     Assert.AreEqual(encodedText, encodedText2);
     // bom & terminator
     bytes = encodedText.ToBytes(true, true);
     Assert.AreEqual(TEST_STRING_HEX_ISO8859_1 + " 00", TestHelper.BytesToHexString(bytes));
     encodedText2 = new EncodedText(EncodedText.TEXT_ENCODING_ISO_8859_1, bytes);
     Assert.AreEqual(encodedText, encodedText2);
 }
예제 #2
0
 public virtual void TestShouldEncodeAndDecodeUTF16BEText()
 {
     EncodedText encodedText = new EncodedText(EncodedText.TEXT_ENCODING_UTF_16BE, UNICODE_TEST_STRING);
     Assert.AreEqual(EncodedText.CHARSET_UTF_16BE, encodedText.GetCharacterSet());
     Assert.AreEqual(UNICODE_TEST_STRING, encodedText.ToString());
     byte[] bytes;
     EncodedText encodedText2;
     // no bom & no terminator
     bytes = encodedText.ToBytes();
     Assert.AreEqual(UNICODE_TEST_STRING_HEX_UTF16BE, TestHelper.BytesToHexString(bytes));
     encodedText2 = new EncodedText(EncodedText.TEXT_ENCODING_UTF_16BE, bytes);
     Assert.AreEqual(encodedText, encodedText2);
     // bom & no terminator
     bytes = encodedText.ToBytes(true);
     Assert.AreEqual("fe ff " + UNICODE_TEST_STRING_HEX_UTF16BE, TestHelper.BytesToHexString(bytes));
     encodedText2 = new EncodedText(EncodedText.TEXT_ENCODING_UTF_16BE, bytes);
     Assert.AreEqual(encodedText, encodedText2);
     // no bom & terminator
     bytes = encodedText.ToBytes(false, true);
     Assert.AreEqual(UNICODE_TEST_STRING_HEX_UTF16BE + " 00 00", TestHelper.BytesToHexString(bytes));
     encodedText2 = new EncodedText(EncodedText.TEXT_ENCODING_UTF_16BE, bytes);
     Assert.AreEqual(encodedText, encodedText2);
     // bom & terminator
     bytes = encodedText.ToBytes(true, true);
     Assert.AreEqual("fe ff " + UNICODE_TEST_STRING_HEX_UTF16BE + " 00 00", TestHelper.BytesToHexString(bytes));
     encodedText2 = new EncodedText(EncodedText.TEXT_ENCODING_UTF_16BE, bytes);
     Assert.AreEqual(encodedText, encodedText2);
 }