本文整理汇总了C#中Portable.Text.Encoding.GetDecoder方法的典型用法代码示例。如果您正苦于以下问题:C# Portable.Text.Encoding.GetDecoder方法的具体用法?C# Portable.Text.Encoding.GetDecoder怎么用?C# Portable.Text.Encoding.GetDecoder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portable.Text.Encoding
的用法示例。
在下文中一共展示了Portable.Text.Encoding.GetDecoder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CharsetFilter
/// <summary>
/// Initializes a new instance of the <see cref="MimeKit.IO.Filters.CharsetFilter"/> class.
/// </summary>
/// <remarks>
/// Creates a new <see cref="CharsetFilter"/> to convert text from the specified
/// source encoding into the target charset encoding.
/// </remarks>
/// <param name="sourceEncoding">Source encoding.</param>
/// <param name="targetEncoding">Target encoding.</param>
/// <exception cref="System.ArgumentNullException">
/// <para><paramref name="sourceEncoding"/> is <c>null</c>.</para>
/// <para>-or-</para>
/// <para><paramref name="targetEncoding"/> is <c>null</c>.</para>
/// </exception>
public CharsetFilter (Encoding sourceEncoding, Encoding targetEncoding)
{
if (sourceEncoding == null)
throw new ArgumentNullException ("sourceEncoding");
if (targetEncoding == null)
throw new ArgumentNullException ("targetEncoding");
SourceEncoding = sourceEncoding;
TargetEncoding = targetEncoding;
decoder = (Decoder) SourceEncoding.GetDecoder ();
encoder = (Encoder) TargetEncoding.GetEncoder ();
}
示例2: ConvertToUnicode
internal static char[] ConvertToUnicode (Encoding encoding, byte[] input, int startIndex, int length, out int charCount)
{
var decoder = encoding.GetDecoder ();
int count = decoder.GetCharCount (input, startIndex, length, true);
char[] output = new char[count];
charCount = decoder.GetChars (input, startIndex, length, output, 0, true);
return output;
}