- [Test]
- public void TestEncodingGetBytes1()
- {
- UTF8Encoding utf8Enc = new UTF8Encoding ();
- string UniCode = "\u0041\u2262\u0391\u002E";
-
- // "A<NOT IDENTICAL TO><ALPHA>." may be encoded as 41 E2 89 A2 CE 91 2E
- // see (RFC 2044)
- byte[] utf8Bytes = utf8Enc.GetBytes (UniCode);
-
- Assertion.AssertEquals ("UTF #1", 0x41, utf8Bytes [0]);
- Assertion.AssertEquals ("UTF #2", 0xE2, utf8Bytes [1]);
- Assertion.AssertEquals ("UTF #3", 0x89, utf8Bytes [2]);
- Assertion.AssertEquals ("UTF #4", 0xA2, utf8Bytes [3]);
- Assertion.AssertEquals ("UTF #5", 0xCE, utf8Bytes [4]);
- Assertion.AssertEquals ("UTF #6", 0x91, utf8Bytes [5]);
- Assertion.AssertEquals ("UTF #7", 0x2E, utf8Bytes [6]);
- }
-
- [Test]
- public void TestEncodingGetBytes2()
- {
- UTF8Encoding utf8Enc = new UTF8Encoding ();
- string UniCode = "\u0048\u0069\u0020\u004D\u006F\u006D\u0020\u263A\u0021";
-
- // "Hi Mom <WHITE SMILING FACE>!" may be encoded as 48 69 20 4D 6F 6D 20 E2 98 BA 21
- // see (RFC 2044)
- byte[] utf8Bytes = new byte [11];
-
- int ByteCnt = utf8Enc.GetBytes (UniCode.ToCharArray(), 0, UniCode.Length, utf8Bytes, 0);
-
- Assertion.AssertEquals ("UTF #1", 11, ByteCnt);
- Assertion.AssertEquals ("UTF #2", 0x48, utf8Bytes [0]);
- Assertion.AssertEquals ("UTF #3", 0x69, utf8Bytes [1]);
- Assertion.AssertEquals ("UTF #4", 0x20, utf8Bytes [2]);
- Assertion.AssertEquals ("UTF #5", 0x4D, utf8Bytes [3]);
- Assertion.AssertEquals ("UTF #6", 0x6F, utf8Bytes [4]);
- Assertion.AssertEquals ("UTF #7", 0x6D, utf8Bytes [5]);
- Assertion.AssertEquals ("UTF #8", 0x20, utf8Bytes [6]);
- Assertion.AssertEquals ("UTF #9", 0xE2, utf8Bytes [7]);
- Assertion.AssertEquals ("UTF #10", 0x98, utf8Bytes [8]);
- Assertion.AssertEquals ("UTF #11", 0xBA, utf8Bytes [9]);
- Assertion.AssertEquals ("UTF #12", 0x21, utf8Bytes [10]);
- }
-
- [Test]
- public void TestDecodingGetChars1()
- {
- UTF8Encoding utf8Enc = new UTF8Encoding ();
- // 41 E2 89 A2 CE 91 2E may be decoded as "A<NOT IDENTICAL TO><ALPHA>."
- // see (RFC 2044)
- byte[] utf8Bytes = new byte [] {0x41, 0xE2, 0x89, 0xA2, 0xCE, 0x91, 0x2E};
- char[] UniCodeChars = utf8Enc.GetChars(utf8Bytes);
-
- Assertion.AssertEquals ("UTF #1", 0x0041, UniCodeChars [0]);
- Assertion.AssertEquals ("UTF #2", 0x2262, UniCodeChars [1]);
- Assertion.AssertEquals ("UTF #3", 0x0391, UniCodeChars [2]);
- Assertion.AssertEquals ("UTF #4", 0x002E, UniCodeChars [3]);
- }
-
- [Test]
+ [Test]
+ public void IsBrowserDisplay ()
+ {
+ Assert.IsTrue (utf8.IsBrowserDisplay);
+ }
+
+ [Test]
+ public void IsBrowserSave ()
+ {
+ Assert.IsTrue (utf8.IsBrowserSave);
+ }
+
+ [Test]
+ public void IsMailNewsDisplay ()
+ {
+ Assert.IsTrue (utf8.IsMailNewsDisplay);
+ }
+
+ [Test]
+ public void IsMailNewsSave ()
+ {
+ Assert.IsTrue (utf8.IsMailNewsSave);
+ }
+
+ [Test]
+ public void TestCompat ()
+ {
+ Assert.IsTrue (new UTF8Encoding ().Equals (new UTF8Encoding ()));
+ }
+
+ [Test]
+ public void TestEncodingGetBytes1()
+ {
+ UTF8Encoding utf8Enc = new UTF8Encoding ();
+ string UniCode = "\u0041\u2262\u0391\u002E";
+
+ // "A<NOT IDENTICAL TO><ALPHA>." may be encoded as 41 E2 89 A2 CE 91 2E
+ // see (RFC 2044)
+ byte[] utf8Bytes = utf8Enc.GetBytes (UniCode);
+
+ Assert.AreEqual (0x41, utf8Bytes [0], "UTF #1");
+ Assert.AreEqual (0xE2, utf8Bytes [1], "UTF #2");
+ Assert.AreEqual (0x89, utf8Bytes [2], "UTF #3");
+ Assert.AreEqual (0xA2, utf8Bytes [3], "UTF #4");
+ Assert.AreEqual (0xCE, utf8Bytes [4], "UTF #5");
+ Assert.AreEqual (0x91, utf8Bytes [5], "UTF #6");
+ Assert.AreEqual (0x2E, utf8Bytes [6], "UTF #7");
+ }
+
+ [Test]
+ public void TestEncodingGetBytes2()
+ {
+ UTF8Encoding utf8Enc = new UTF8Encoding ();
+ string UniCode = "\u0048\u0069\u0020\u004D\u006F\u006D\u0020\u263A\u0021";
+
+ // "Hi Mom <WHITE SMILING FACE>!" may be encoded as 48 69 20 4D 6F 6D 20 E2 98 BA 21
+ // see (RFC 2044)
+ byte[] utf8Bytes = new byte [11];
+
+ int ByteCnt = utf8Enc.GetBytes (UniCode.ToCharArray(), 0, UniCode.Length, utf8Bytes, 0);
+ Assert.AreEqual (11, ByteCnt, "UTF #1");
+ Assert.AreEqual (0x48, utf8Bytes [0], "UTF #2");
+ Assert.AreEqual (0x69, utf8Bytes [1], "UTF #3");
+ Assert.AreEqual (0x20, utf8Bytes [2], "UTF #4");
+ Assert.AreEqual (0x4D, utf8Bytes [3], "UTF #5");
+ Assert.AreEqual (0x6F, utf8Bytes [4], "UTF #6");
+ Assert.AreEqual (0x6D, utf8Bytes [5], "UTF #7");
+ Assert.AreEqual (0x20, utf8Bytes [6], "UTF #8");
+ Assert.AreEqual (0xE2, utf8Bytes [7], "UTF #9");
+ Assert.AreEqual (0x98, utf8Bytes [8], "UTF #10");
+ Assert.AreEqual (0xBA, utf8Bytes [9], "UTF #11");
+ Assert.AreEqual (0x21, utf8Bytes [10], "UTF #12");
+ }
+
+ [Test]
+ public void TestDecodingGetChars1()
+ {
+ UTF8Encoding utf8Enc = new UTF8Encoding ();
+ // 41 E2 89 A2 CE 91 2E may be decoded as "A<NOT IDENTICAL TO><ALPHA>."
+ // see (RFC 2044)
+ byte[] utf8Bytes = new byte [] {0x41, 0xE2, 0x89, 0xA2, 0xCE, 0x91, 0x2E};
+ char[] UniCodeChars = utf8Enc.GetChars(utf8Bytes);
+
+ Assert.AreEqual (0x0041, UniCodeChars [0], "UTF #1");
+ Assert.AreEqual (0x2262, UniCodeChars [1], "UTF #2");
+ Assert.AreEqual (0x0391, UniCodeChars [2], "UTF #3");
+ Assert.AreEqual (0x002E, UniCodeChars [3], "UTF #4");
+ }
+
+ [Test]