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


C# UTF32Encoding.GetByteCount方法代码示例

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


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

示例1: GetByteCount2

		[Category ("NotDotNet")] // A1/B1 return 24 on MS
		public void GetByteCount2 ()
		{
			string s = "za\u0306\u01FD\u03B2\uD8FF\uDCFF";

			UTF32Encoding le = new UTF32Encoding (false, true);
			Assert.AreEqual (28, le.GetByteCount (s), "#A1");
			Assert.AreEqual (0, le.GetByteCount (string.Empty), "#A2");

			UTF32Encoding be = new UTF32Encoding (true, true);
			Assert.AreEqual (28, be.GetByteCount (s), "#B1");
			Assert.AreEqual (0, be.GetByteCount (string.Empty), "#B2");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:13,代码来源:UTF32EncodingTest.cs

示例2: GetByteCount1

		[Category ("NotDotNet")] // A1/B1 return 24 on MS
		public void GetByteCount1 ()
		{
			char [] chars = new char[] { 'z', 'a', '\u0306',
				'\u01FD', '\u03B2', '\uD8FF', '\uDCFF' };

			UTF32Encoding le = new UTF32Encoding (false, true);
			Assert.AreEqual (28, le.GetByteCount (chars), "#A1");
			Assert.AreEqual (0, le.GetByteCount (new char [0]), "#A2");

			UTF32Encoding be = new UTF32Encoding (true, true);
			Assert.AreEqual (28, be.GetByteCount (chars), "#B1");
			Assert.AreEqual (0, be.GetByteCount (new char [0]), "#B2");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:14,代码来源:UTF32EncodingTest.cs

示例3: GetByteCount

		[Test] // GetByteCount (Char *)
		public unsafe void GetByteCount3 ()
		{
			char [] chars = new char[] { 'z', 'a', '\u0306',
				'\u01FD', '\u03B2', '\uD8FF', '\uDCFF' };

			fixed (char* cp = chars) {
				UTF32Encoding le = new UTF32Encoding (false, true);
				Assert.AreEqual (12, le.GetByteCount (cp, 3), "#A1");
				Assert.AreEqual (4, le.GetByteCount (cp, 1), "#A2");
				Assert.AreEqual (0, le.GetByteCount (cp, 0), "#A3");
				Assert.AreEqual (24, le.GetByteCount (cp, 6), "#A4");
				//Assert.AreEqual (24, le.GetByteCount (cp, 7), "#A5");

				UTF32Encoding be = new UTF32Encoding (true, true);
				Assert.AreEqual (12, be.GetByteCount (cp, 3), "#B1");
				Assert.AreEqual (4, be.GetByteCount (cp, 1), "#B2");
				Assert.AreEqual (0, be.GetByteCount (cp, 0), "#B3");
				Assert.AreEqual (24, be.GetByteCount (cp, 6), "#B4");
				//Assert.AreEqual (24, be.GetByteCount (cp, 7), "#B5");
			}
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:22,代码来源:UTF32EncodingTest.cs


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