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


C# Decoder.GetChars方法代码示例

本文整理汇总了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);
 }
开发者ID:ESgarbi,项目名称:corefx,代码行数:5,代码来源:DecoderGetChars2.cs

示例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/>");
    }
开发者ID:paopaofeng,项目名称:dp2,代码行数:20,代码来源:Chat.aspx.cs

示例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));
        }
开发者ID:ESgarbi,项目名称:corefx,代码行数:26,代码来源:NegativeEncodingTests.cs


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