本文整理汇总了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");
}
示例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");
}
示例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");
}
}