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