UTF7Encoding.GetDecoder 메서드

정의

UTF-7로 인코딩된 바이트 시퀀스를 유니코드 문자 시퀀스로 변환하는 디코더를 가져옵니다.

public override System.Text.Decoder GetDecoder ();

반환

Decoder

UTF-7로 인코딩된 바이트 시퀀스를 유니코드 문자 시퀀스로 변환하는 Decoder입니다.

예제

다음 코드 예제에서는 메서드를 사용하여 GetDecoder 디코더를 가져와 UTF-7로 인코딩된 바이트를 문자 시퀀스로 변환하는 방법을 보여 줍니다.

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();
    }
}

설명

Decoder.GetChars메서드는 GetChars 이 클래스의 메서드와 비슷한 방식으로 순차 바이트 블록을 문자의 순차 블록으로 변환 합니다. 그러나 Decoder 호출 간에 상태 정보를 유지 관리하므로 블록에 걸쳐 있는 바이트 시퀀스를 올바르게 디코딩할 수 있습니다. Decoder또한는 데이터 블록 끝에 후행 바이트를 보존 하 고 다음 디코딩 작업에서 후행 바이트를 사용 합니다. 따라서 GetDecoderGetEncoder 는 네트워크 전송 및 파일 작업에 유용 합니다. 이러한 작업은 대개 전체 데이터 스트림 대신 데이터 블록을 처리 하기 때문입니다.

적용 대상

추가 정보