예제 #1
0
		public void TestEncodingGetBytes1()
		{
			UnixEncoding unixEnc = new UnixEncoding ();
			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[] unixBytes = unixEnc.GetBytes (UniCode);

			Assert.AreEqual (0x41, unixBytes [0], "UTF #1");
			Assert.AreEqual (0xE2, unixBytes [1], "UTF #2");
			Assert.AreEqual (0x89, unixBytes [2], "UTF #3");
			Assert.AreEqual (0xA2, unixBytes [3], "UTF #4");
			Assert.AreEqual (0xCE, unixBytes [4], "UTF #5");
			Assert.AreEqual (0x91, unixBytes [5], "UTF #6");
			Assert.AreEqual (0x2E, unixBytes [6], "UTF #7");
		}
예제 #2
0
		public void TestEncodingGetBytes2()
		{
			UnixEncoding unixEnc = new UnixEncoding ();
			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[] unixBytes = new byte [11];

			int ByteCnt = unixEnc.GetBytes (UniCode.ToCharArray(), 0, UniCode.Length, unixBytes, 0);

			Assert.AreEqual (11, ByteCnt, "UTF #1");
			Assert.AreEqual (0x48, unixBytes [0], "UTF #2");
			Assert.AreEqual (0x69, unixBytes [1], "UTF #3");
			Assert.AreEqual (0x20, unixBytes [2], "UTF #4");
			Assert.AreEqual (0x4D, unixBytes [3], "UTF #5");
			Assert.AreEqual (0x6F, unixBytes [4], "UTF #6");
			Assert.AreEqual (0x6D, unixBytes [5], "UTF #7");
			Assert.AreEqual (0x20, unixBytes [6], "UTF #8");
			Assert.AreEqual (0xE2, unixBytes [7], "UTF #9");
			Assert.AreEqual (0x98, unixBytes [8], "UTF #10");
			Assert.AreEqual (0xBA, unixBytes [9], "UTF #11");
			Assert.AreEqual (0x21, unixBytes [10], "UTF #12");
		}