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


C# Decoder.process方法代码示例

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


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

示例1: decode

        /// <summary>
        /// Decode the Base64-encoded data in input and return the data in
        /// a new byte array.
        /// <p/>
        /// <para>The padding '=' characters at the end are considered optional, but
        /// if any are present, there must be the correct number of them.
        /// 
        /// </para>
        /// </summary>
        /// <param name="input">  the data to decode </param>
        /// <param name="offset"> the position within the input array at which to start </param>
        /// <param name="len">    the number of bytes of input to decode </param>
        /// <param name="flags">  controls certain features of the decoded output.
        ///               Pass {@code DEFAULT} to decode standard Base64. </param>
        /// <exception cref="IllegalArgumentException"> if the input contains
        ///                                  incorrect padding </exception>
        public static byte[] decode(byte[] input, int offset, int len, int flags)
        {
            // Allocate space for the most data the input could represent.
            // (It could contain less if it contains whitespace, etc.)
            Decoder decoder = new Decoder(flags, new byte[len * 3 / 4]);

            if (!decoder.process(input, offset, len, true))
            {
                throw new System.ArgumentException("bad base-64");
            }

            // Maybe we got lucky and allocated exactly enough output space.
            if (decoder.op == decoder.output.Length)
            {
                return decoder.output;
            }

            // Need to shorten the array, so allocate a new one of the
            // right size and copy.
            byte[] temp = new byte[decoder.op];
            Array.Copy(decoder.output, 0, temp, 0, decoder.op);
            return temp;
        }
开发者ID:pili-engineering,项目名称:pili-sdk-csharp,代码行数:39,代码来源:Base64.cs


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