Decoder 클래스

정의

인코딩된 바이트 시퀀스를 문자 집합으로 변환합니다.

public ref class Decoder abstract
public abstract class Decoder
[System.Serializable]
public abstract class Decoder
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class Decoder
type Decoder = class
[<System.Serializable>]
type Decoder = class
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type Decoder = class
Public MustInherit Class Decoder
상속
Decoder
특성

예제

다음 예제에서는 두 개의 서로 다른 바이트 배열을 문자 배열로 변환 하는 데 사용 Decoder 하는 방법을 보여 줍니다. 문자의 바이트 중 하나가 배열에 걸쳐 있습니다. 이는 스트림을 읽을 때 개체가 StreamReader 내부적으로 수행하는 작업과 비슷합니다.

using namespace System;
using namespace System::Text;
int main()
{
   
   // These bytes in UTF-8 correspond to 3 different Unicode
   // characters: space (U+0020), # (U+0023), and the biohazard
   // symbol (U+2623).  Note the biohazard symbol requires 3 bytes
   // in UTF-8 (hexadecimal e2, 98, a3).  Decoders store state across
   // multiple calls to GetChars, handling the case when one char
   // is in multiple byte arrays.
   array<Byte>^bytes1 = {0x20,0x23,0xe2};
   array<Byte>^bytes2 = {0x98,0xa3};
   array<Char>^chars = gcnew array<Char>(3);
   Decoder^ d = Encoding::UTF8->GetDecoder();
   int charLen = d->GetChars( bytes1, 0, bytes1->Length, chars, 0 );
   
   // The value of charLen should be 2 now.
   charLen += d->GetChars( bytes2, 0, bytes2->Length, chars, charLen );
   for ( UInt16 index(0); index < chars->Length; ++index )
   {
      Console::Write( "U+{0:X4}  ", static_cast<UInt16>(chars[ index ]) );

   }
}
using System;
using System.Text;
public class dec
{
    public static void Main()
    {
        // These bytes in UTF-8 correspond to 3 different Unicode
        // characters: space (U+0020), # (U+0023), and the biohazard
        // symbol (U+2623).  Note the biohazard symbol requires 3 bytes
        // in UTF-8 (hexadecimal e2, 98, a3).  Decoders store state across
        // multiple calls to GetChars, handling the case when one char
        // is in multiple byte arrays.
        byte[] bytes1 = { 0x20, 0x23, 0xe2 };
        byte[] bytes2 = { 0x98, 0xa3 };
        char[] chars = new char[3];

        Decoder d = Encoding.UTF8.GetDecoder();
        int charLen = d.GetChars(bytes1, 0, bytes1.Length, chars, 0);
        // The value of charLen should be 2 now.
        charLen += d.GetChars(bytes2, 0, bytes2.Length, chars, charLen);
        foreach(char c in chars)
            Console.Write("U+{0:X4}  ", (ushort)c);
    }
}
Imports System.Text

Public Class dec
    
    Public Shared Sub Main()
        ' These bytes in UTF-8 correspond to 3 different Unicode
        ' characters: space (U+0020), # (U+0023), and the biohazard
        ' symbol (U+2623).  Note the biohazard symbol requires 3 bytes
        ' in UTF-8 (hexadecimal e2, 98, a3).  Decoders store state across
        ' multiple calls to GetChars, handling the case when one char
        ' is in multiple byte arrays.
        Dim bytes1 As Byte() =  {&H20, &H23, &HE2}
        Dim bytes2 As Byte() =  {&H98, &HA3}
        Dim chars(3) As Char
        
        Dim d As Decoder = Encoding.UTF8.GetDecoder()
        Dim charLen As Integer = d.GetChars(bytes1, 0, bytes1.Length, chars, 0)
        ' The value of charLen should be 2 now.
        charLen += d.GetChars(bytes2, 0, bytes2.Length, chars, charLen)
        Dim c As Char
        For Each c In  chars
            Console.Write("U+{0:X4}  ", Convert.ToUInt16(c) )
        Next c
    End Sub
End Class

설명

클래스 구현 Decoder 의 instance 가져오려면 구현의 메서드를 호출 GetDecoder 합니다Encoding.

GetCharCount메서드는 바이트 시퀀스를 디코딩하는 문자 수를 결정 하 고 GetChars 메서드는 실제 디코딩을 수행 합니다. 클래스에서 사용할 수 있는 이러한 메서드의 여러 버전이 Decoder 있습니다. 자세한 내용은 Encoding.GetChars를 참조하세요. 개체는 Decoder 블록에 걸쳐 있는 바이트 시퀀스를 올바르게 디코딩할 GetChars 수 있도록 또는 Convert 메서드에 대한 연속 호출 간에 상태 정보를 유지 관리합니다. Decoder또한는 데이터 블록 끝에 후행 바이트를 보존 하 고 다음 디코딩 작업에서 후행 바이트를 사용 합니다. 따라서 GetDecoderGetEncoder 는 네트워크 전송 및 파일 작업에 유용합니다. 이러한 작업은 전체 데이터 스트림 대신 데이터 블록을 처리하는 경우가 많기 때문입니다.

참고

애플리케이션 데이터의 스트림을 사용 하 여 완료 되 면 상태 정보를 설정 하 여 플러시 되도록 확인 해야 합니다 flush 매개 변수를 true 적절 한 메서드 호출에서 합니다. 예외가 발생 하거나 애플리케이션 스트림 전환 하는 경우 호출 해야 하는 경우 Reset 의 내부 상태를 지울지를 Decoder 개체입니다.

구현자 참고

애플리케이션이 클래스에서 상속 하는 경우에 모든 멤버를 재정의 해야 합니다.

생성자

Decoder()

Decoder 클래스의 새 인스턴스를 초기화합니다.

속성

Fallback

현재 DecoderFallback 개체에 대한 Decoder 개체를 가져오거나 설정합니다.

FallbackBuffer

현재 DecoderFallbackBuffer 개체와 관련된 Decoder 개체를 가져옵니다.

메서드

Convert(Byte*, Int32, Char*, Int32, Boolean, Int32, Int32, Boolean)

인코딩된 바이트 버퍼를 UTF-16으로 인코딩된 문자로 변환하고 그 결과를 다른 버퍼에 저장합니다.

Convert(Byte[], Int32, Int32, Char[], Int32, Int32, Boolean, Int32, Int32, Boolean)

인코딩된 바이트 배열을 UTF-16으로 인코딩된 문자로 변환하고 그 결과를 문자 배열에 저장합니다.

Convert(ReadOnlySpan<Byte>, Span<Char>, Boolean, Int32, Int32, Boolean)

인코딩된 바이트 범위를 UTF-16 인코딩 문자로 변환하고, 그 결과를 다른 범위 버퍼에 저장합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetCharCount(Byte*, Int32, Boolean)

파생 클래스에서 재정의되면 지정한 바이트 포인터에서 시작하는 바이트 시퀀스를 디코딩하여 생성되는 문자 수를 계산합니다. 매개 변수는 계산 후 디코더의 내부 상태를 지울지 여부를 나타냅니다.

GetCharCount(Byte[], Int32, Int32)

파생 클래스에서 재정의되면 지정한 바이트 배열의 바이트 시퀀스를 디코딩하여 생성되는 문자 수를 계산합니다.

GetCharCount(Byte[], Int32, Int32, Boolean)

파생 클래스에서 재정의되면 지정한 바이트 배열의 바이트 시퀀스를 디코딩하여 생성되는 문자 수를 계산합니다. 매개 변수는 계산 후 디코더의 내부 상태를 지울지 여부를 나타냅니다.

GetCharCount(ReadOnlySpan<Byte>, Boolean)

파생 클래스에서 재정의할 경우, 범위 내의 바이트 시퀀스를 디코딩 하여 생성되는 문자 수를 계산합니다. 매개 변수는 계산 후 디코더의 내부 상태를 지울지 여부를 나타냅니다.

GetChars(Byte*, Int32, Char*, Int32, Boolean)

파생 클래스에서 재정의될 때 지정한 바이트 포인터에서 시작하는 바이트 시퀀스 및 내부 버퍼의 모든 바이트를 지정한 문자 포인터에서 시작하여 저장되는 문자 집합으로 디코딩합니다. 매개 변수는 변환 후 디코더의 내부 상태를 지울지 여부를 나타냅니다.

GetChars(Byte[], Int32, Int32, Char[], Int32)

파생 클래스에서 재정의될 때 지정한 바이트 배열의 바이트 시퀀스 및 내부 버퍼의 모든 바이트를 지정한 문자 배열로 디코딩합니다.

GetChars(Byte[], Int32, Int32, Char[], Int32, Boolean)

파생 클래스에서 재정의될 때 지정한 바이트 배열의 바이트 시퀀스 및 내부 버퍼의 모든 바이트를 지정한 문자 배열로 디코딩합니다. 매개 변수는 변환 후 디코더의 내부 상태를 지울지 여부를 나타냅니다.

GetChars(ReadOnlySpan<Byte>, Span<Char>, Boolean)

파생 클래스에서 재정의할 경우, 범위 바이트 시퀀스와 내부 버퍼의 모든 바이트를 지정된 문자 포인터에서 시작하여 저장되는 문자 집합으로 디코딩합니다. 매개 변수는 변환 후 디코더의 내부 상태를 지울지 여부를 나타냅니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
Reset()

파생 클래스에서 재정의될 때 디코더를 다시 초기 상태로 설정합니다.

ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

확장 메서드

Convert(Decoder, ReadOnlySequence<Byte>, IBufferWriter<Char>, Boolean, Int64, Boolean)

ReadOnlySequence<T>을 UTF-16으로 인코딩된 문자로 변환하고 결과를 writer에 씁니다.

Convert(Decoder, ReadOnlySpan<Byte>, IBufferWriter<Char>, Boolean, Int64, Boolean)

decoder를 사용하여 ReadOnlySpan<T>을 문자로 변환하고 결과를 writer에 씁니다.

적용 대상

추가 정보