UTF7Encoding.GetDecoder 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
UTF-7로 인코딩된 바이트 시퀀스를 유니코드 문자 시퀀스로 변환하는 디코더를 가져옵니다.
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
반품
Decoder UTF-7로 인코딩된 바이트 시퀀스를 유니코드 문자 시퀀스로 변환하는 A입니다.
예제
다음 코드 예제에서는 메서드를 사용하여 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();
}
}
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
설명
이 메서드는 Decoder.GetChars 이 클래스의 메서드와 비슷한 방식으로 순차적 바이트 블록을 문자의 순차 블록으로 GetChars 변환합니다. 그러나 Decoder 호출 간에 상태 정보를 유지 관리하므로 블록에 걸쳐 있는 바이트 시퀀스를 올바르게 디코딩할 수 있습니다. Decoder 또한 데이터 블록의 끝에 후행 바이트를 유지하고 다음 디코딩 작업에서 후행 바이트를 사용합니다. 따라서 GetDecoderGetEncoder 이러한 작업은 전체 데이터 스트림 대신 데이터 블록을 처리하는 경우가 많기 때문에 네트워크 전송 및 파일 작업에 유용합니다.