本文整理汇总了C#中Decoder.GetChars方法的典型用法代码示例。如果您正苦于以下问题:C# Decoder.GetChars方法的具体用法?C# Decoder.GetChars怎么用?C# Decoder.GetChars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Decoder
的用法示例。
在下文中一共展示了Decoder.GetChars方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerificationHelper
private void VerificationHelper(Decoder decoder, byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex, bool flush, int expected, string errorno)
{
int actual = decoder.GetChars(bytes, byteIndex, byteCount, chars, charIndex, flush);
Assert.Equal(expected, actual);
}
示例2: GetResultText
static string GetResultText(Decoder decoder, byte[] baResult)
{
if (baResult == null)
return "";
if (baResult.Length == 0)
return "";
// Decoder ResultTextDecoder = Encoding.UTF8.GetDecoder;
char[] chars = new char[baResult.Length];
int nCharCount = decoder.GetChars(
baResult,
0,
baResult.Length,
chars,
0);
Debug.Assert(nCharCount <= baResult.Length, "");
return new string(chars, 0, nCharCount).Replace("\r", "<br/>");
}
示例3: Decoder_GetChars_Invalid
public static void Decoder_GetChars_Invalid(Encoding _, Decoder decoder, bool flush)
{
// Bytes is null
Assert.Throws<ArgumentNullException>("bytes", () => decoder.GetChars(null, 0, 0, new char[4], 0, flush));
// ByteIndex is invalid
Assert.Throws<ArgumentOutOfRangeException>("byteIndex", () => decoder.GetChars(new byte[4], -1, 0, new char[4], 0, flush));
Assert.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetChars(new byte[4], 5, 0, new char[4], 0, flush));
// ByteCount is invalid
Assert.Throws<ArgumentOutOfRangeException>("byteCount", () => decoder.GetChars(new byte[4], 0, -1, new char[4], 0, flush));
Assert.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetChars(new byte[4], 0, 5, new char[4], 0, flush));
Assert.Throws<ArgumentOutOfRangeException>("bytes", () => decoder.GetChars(new byte
[4], 1, 4, new char[4], 0, flush));
// Chars is null
Assert.Throws<ArgumentNullException>("chars", () => decoder.GetChars(new byte[1], 0, 1, null, 0, flush));
// CharIndex is invalid
Assert.Throws<ArgumentOutOfRangeException>("charIndex", () => decoder.GetChars(new byte[1], 0, 1, new char[4], -1, flush));
Assert.Throws<ArgumentOutOfRangeException>("charIndex", () => decoder.GetChars(new byte[1], 0, 1, new char[4], 5, flush));
// Chars does not have enough space
int charCount = decoder.GetCharCount(new byte[4], 0, 4, flush);
Assert.Throws<ArgumentException>("chars", () => decoder.GetChars(new byte[4], 0, 4, new char[charCount - 1], 0, flush));
}