本文整理汇总了C#中System.Text.Decoder类的典型用法代码示例。如果您正苦于以下问题:C# Decoder类的具体用法?C# Decoder怎么用?C# Decoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Decoder类属于System.Text命名空间,在下文中一共展示了Decoder类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Text;
public class dec
{
public static void Main()
{
// These bytes in UTF-8 correspond to 3 different Unicode
// characters: space (U+0020), # (U+0023), and the biohazard
// symbol (U+2623). Note the biohazard symbol requires 3 bytes
// in UTF-8 (hexadecimal e2, 98, a3). Decoders store state across
// multiple calls to GetChars, handling the case when one char
// is in multiple byte arrays.
byte[] bytes1 = { 0x20, 0x23, 0xe2 };
byte[] bytes2 = { 0x98, 0xa3 };
char[] chars = new char[3];
Decoder d = Encoding.UTF8.GetDecoder();
int charLen = d.GetChars(bytes1, 0, bytes1.Length, chars, 0);
// The value of charLen should be 2 now.
charLen += d.GetChars(bytes2, 0, bytes2.Length, chars, charLen);
foreach(char c in chars)
Console.Write("U+{0:X4} ", (ushort)c);
}
}