当前位置: 首页>>代码示例>>C#>>正文


C# UTF7Encoding.GetChars方法代码示例

本文整理汇总了C#中System.Text.UTF7Encoding.GetChars方法的典型用法代码示例。如果您正苦于以下问题:C# UTF7Encoding.GetChars方法的具体用法?C# UTF7Encoding.GetChars怎么用?C# UTF7Encoding.GetChars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Text.UTF7Encoding的用法示例。


在下文中一共展示了UTF7Encoding.GetChars方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PosTest2

 public void PosTest2()
 {
     Char[] chars;
     Byte[] bytes = new Byte[] { };
     UTF7Encoding UTF7 = new UTF7Encoding();
     int charCount = UTF7.GetCharCount(bytes, 0, 0);
     chars = new Char[] { };
     int charsDecodedCount = UTF7.GetChars(bytes, 0, 0, chars, 0);
     Assert.Equal(0, charsDecodedCount);
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:10,代码来源:UTF7EncodingGetChars.cs

示例2: NegTest1

 public void NegTest1()
 {
     Char[] chars;
     Byte[] bytes = null;
     UTF7Encoding UTF7 = new UTF7Encoding();
     chars = new Char[] { };
     Assert.Throws<ArgumentNullException>(() =>
     {
         int charsDecodedCount = UTF7.GetChars(bytes, 0, 0, chars, 0);
     });
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:11,代码来源:UTF7EncodingGetChars.cs

示例3: PosTest1

 public void PosTest1()
 {
     Char[] chars;
     Byte[] bytes = new Byte[] {
          85,  84,  70,  55,  32,  69, 110,
          99, 111, 100, 105, 110, 103,  32,
          69, 120,  97, 109, 112, 108, 101
     };
     UTF7Encoding UTF7 = new UTF7Encoding();
     int charCount = UTF7.GetCharCount(bytes, 2, 8);
     chars = new Char[charCount];
     int charsDecodedCount = UTF7.GetChars(bytes, 2, 8, chars, 0);
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:13,代码来源:UTF7EncodingGetChars.cs

示例4: NegTest2

 public void NegTest2()
 {
     Char[] chars = null;
     Byte[] bytes = new Byte[] {
          85,  84,  70,  55,  32,  69, 110,
          99, 111, 100, 105, 110, 103,  32,
          69, 120,  97, 109, 112, 108, 101
     };
     UTF7Encoding UTF7 = new UTF7Encoding();
     Assert.Throws<ArgumentNullException>(() =>
     {
         int charsDecodedCount = UTF7.GetChars(bytes, 2, 8, chars, 0);
     });
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:14,代码来源:UTF7EncodingGetChars.cs

示例5: RFC1642_Example4

		public void RFC1642_Example4 ()
		{
			string UniCodeString = "\u0049\u0074\u0065\u006D\u0020\u0033\u0020\u0069\u0073\u0020\u00A3\u0031\u002E";
			char[] expected = UniCodeString.ToCharArray ();

			byte[] UTF7Bytes = new byte[] { 0x49, 0x74, 0x65, 0x6D, 0x20, 0x33, 0x20, 0x69, 0x73, 0x20, 0x2B, 0x41, 0x4B, 0x4D, 0x2D, 0x31, 0x2E };

			UTF7Encoding UTF7enc = new UTF7Encoding ();
			char[] actual = UTF7enc.GetChars (UTF7Bytes);

			// "Item 3 is +AKM-1." is decoded as "Item 3 is <POUND SIGN>1."
			AssertEquals ("UTF #1", expected [0], actual [0]);
			AssertEquals ("UTF #2", expected [1], actual [1]);
			AssertEquals ("UTF #3", expected [2], actual [2]);
			AssertEquals ("UTF #4", expected [3], actual [3]);
			AssertEquals ("UTF #5", expected [4], actual [4]);
			AssertEquals ("UTF #6", expected [5], actual [5]);
			AssertEquals ("UTF #7", expected [6], actual [6]);
			AssertEquals ("UTF #8", expected [7], actual [7]);
			AssertEquals ("UTF #9", expected [8], actual [8]);
			AssertEquals ("UTF #10", expected [9], actual [9]);
			AssertEquals ("UTF #11", expected [10], actual [10]);
			AssertEquals ("UTF #12", expected [11], actual [11]);
			AssertEquals ("UTF #13", expected [12], actual [12]);

			AssertEquals ("GetString", UniCodeString, UTF7enc.GetString (UTF7Bytes));
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:27,代码来源:UTF7EncodingTest.cs

示例6: RFC1642_Example3

		public void RFC1642_Example3 ()
		{
			string UniCodeString = "\u65E5\u672C\u8A9E";
			char[] expected = UniCodeString.ToCharArray ();

			byte[] UTF7Bytes = new byte[] { 0x2B, 0x5A, 0x65, 0x56, 0x6E, 0x4C, 0x49, 0x71, 0x65, 0x2D };

			UTF7Encoding UTF7enc = new UTF7Encoding ();
			char[] actual = UTF7enc.GetChars (UTF7Bytes);

			// "+ZeVnLIqe-" is decoded as Japanese "nihongo"
			AssertEquals ("UTF #1", expected [0], actual [0]);
			AssertEquals ("UTF #2", expected [1], actual [1]);
			AssertEquals ("UTF #3", expected [2], actual [2]);

			AssertEquals ("GetString", UniCodeString, UTF7enc.GetString (UTF7Bytes));
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:17,代码来源:UTF7EncodingTest.cs

示例7: RFC1642_Example2

		public void RFC1642_Example2 ()
		{
			string UniCodeString = "\u0048\u0069\u0020\u004D\u006F\u004D\u0020\u263A\u0021";
			char[] expected = UniCodeString.ToCharArray ();

			byte[] UTF7Bytes = new byte[] { 0x48, 0x69, 0x20, 0x4D, 0x6F, 0x4D, 0x20, 0x2B, 0x4A, 0x6A, 0x6F, 0x41, 0x49, 0x51, 0x2D };

			UTF7Encoding UTF7enc = new UTF7Encoding ();
			char[] actual = UTF7enc.GetChars (UTF7Bytes);

			// "Hi Mom +Jjo-!" is decoded as "Hi Mom <WHITE SMILING FACE>!"
			AssertEquals ("UTF #1", expected [0], actual [0]);
			AssertEquals ("UTF #2", expected [1], actual [1]);
			AssertEquals ("UTF #3", expected [2], actual [2]);
			AssertEquals ("UTF #4", expected [3], actual [3]);
			AssertEquals ("UTF #5", expected [4], actual [4]);
			AssertEquals ("UTF #6", expected [5], actual [5]);
			AssertEquals ("UTF #7", expected [6], actual [6]);
			AssertEquals ("UTF #8", expected [7], actual [7]);
			AssertEquals ("UTF #9", expected [8], actual [8]);

			AssertEquals ("GetString", UniCodeString, UTF7enc.GetString (UTF7Bytes));
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:23,代码来源:UTF7EncodingTest.cs

示例8: RFC1642_Example1

		public void RFC1642_Example1 ()
		{
			string UniCodeString = "\u0041\u2262\u0391\u002E";
			char[] expected = UniCodeString.ToCharArray ();

			byte[] UTF7Bytes = new byte [] {0x41, 0x2B, 0x49, 0x6D, 0x49, 0x44, 0x6B,  0x51, 0x2D, 0x2E};
			UTF7Encoding UTF7enc = new UTF7Encoding ();
			char[] actual = UTF7enc.GetChars (UTF7Bytes);

			// "A+ImIDkQ-." is decoded as "A<NOT IDENTICAL TO><ALPHA>." see RFC 1642
			AssertEquals ("UTF #1", expected [0], actual [0]);
			AssertEquals ("UTF #2", expected [1], actual [1]);
			AssertEquals ("UTF #3", expected [2], actual [2]);
			AssertEquals ("UTF #4", expected [3], actual [3]);

			AssertEquals ("GetString", UniCodeString, UTF7enc.GetString (UTF7Bytes));
                }
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:17,代码来源:UTF7EncodingTest.cs

示例9: NegTest4

 public void NegTest4()
 {
     Char[] chars;
     Byte[] bytes = new Byte[] {
          85,  84,  70,  55,  32,  69, 110,
          99, 111, 100, 105, 110, 103,  32,
          69, 120,  97, 109, 112, 108, 101
     };
     UTF7Encoding UTF7 = new UTF7Encoding();
     int charCount = UTF7.GetCharCount(bytes, 2, 8);
     chars = new Char[charCount];
     Assert.Throws<ArgumentOutOfRangeException>(() =>
     {
         int charsDecodedCount = UTF7.GetChars(bytes, 2, -8, chars, 0);
     });
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:16,代码来源:UTF7EncodingGetChars.cs


注:本文中的System.Text.UTF7Encoding.GetChars方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。