UTF7Encoding.GetDecoder Yöntem

Tanım

UTF-7 kodlanmış bayt dizisini Unicode karakter dizisine dönüştüren bir kod çözücü alır.

public:
 override System::Text::Decoder ^ GetDecoder();
public override System.Text.Decoder GetDecoder();
override this.GetDecoder : unit -> System.Text.Decoder
Public Overrides Function GetDecoder () As Decoder

Döndürülenler

Decoder UTF-7 kodlanmış bayt dizisini Unicode karakter dizisine dönüştüren bir.

Örnekler

Aşağıdaki kod örneğinde, UTF-7 kodlanmış baytları bir karakter dizisine dönüştürmek üzere kod çözücü elde etmek için yönteminin nasıl kullanılacağı GetDecoder gösterilmektedir.

using System;
using System.Text;

class UTF7EncodingExample {
    public static void Main() {
        Char[] chars;
        Byte[] bytes = new Byte[] {
            99, 43, 65, 119, 67, 103, 111, 65, 45
        };

        Decoder utf7Decoder = Encoding.UTF7.GetDecoder();

        int charCount = utf7Decoder.GetCharCount(bytes, 0, bytes.Length);
        chars = new Char[charCount];
        int charsDecodedCount = utf7Decoder.GetChars(bytes, 0, bytes.Length, chars, 0);

        Console.WriteLine(
            "{0} characters used to decode bytes.", charsDecodedCount
        );

        Console.Write("Decoded chars: ");
        foreach (Char c in chars) {
            Console.Write("[{0}]", c);
        }
        Console.WriteLine();
    }
}
Imports System.Text

Class UTF7EncodingExample
    
    Public Shared Sub Main()
        Dim chars() As Char
        Dim bytes() As Byte = {99, 43, 65, 119, 67, 103, 111, 65, 45}
        
        Dim utf7Decoder As Decoder = Encoding.UTF7.GetDecoder()
        
        Dim charCount As Integer = utf7Decoder.GetCharCount(bytes, 0, bytes.Length)
        chars = New Char(charCount - 1) {}
        Dim charsDecodedCount As Integer = utf7Decoder.GetChars(bytes, 0, bytes.Length, chars, 0)
        
        Console.WriteLine("{0} characters used to decode bytes.", charsDecodedCount)
        
        Console.Write("Decoded chars: ")
        Dim c As Char
        For Each c In  chars
            Console.Write("[{0}]", c)
        Next c
        Console.WriteLine()
    End Sub
End Class

Açıklamalar

yöntemi, Decoder.GetChars baytların sıralı bloklarını bu sınıfın yöntemine benzer şekilde sıralı karakter bloklarına GetChars dönüştürür. Ancak, bloklara Decoder yayılan bayt dizilerinin kodunu doğru bir şekilde çözebilmesi için çağrılar arasında durum bilgilerini korur. ayrıca Decoder veri bloklarının sonundaki sondaki baytları korur ve sonraki kod çözme işleminde sondaki baytları kullanır. Bu nedenle ve GetDecoderGetEncoder ağ iletimi ve dosya işlemleri için yararlıdır çünkü bu işlemler genellikle tam bir veri akışı yerine veri bloklarıyla ilgilenir.

Şunlara uygulanır

Ayrıca bkz.