Decoder.GetChars 메서드

정의

파생 클래스에서 재정의되면 바이트 시퀀스를 문자 집합으로 디코딩합니다.

오버로드

GetChars(ReadOnlySpan<Byte>, Span<Char>, 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)

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

public:
 virtual int GetChars(ReadOnlySpan<System::Byte> bytes, Span<char> chars, bool flush);
public virtual int GetChars (ReadOnlySpan<byte> bytes, Span<char> chars, bool flush);
abstract member GetChars : ReadOnlySpan<byte> * Span<char> * bool -> int
override this.GetChars : ReadOnlySpan<byte> * Span<char> * bool -> int
Public Overridable Function GetChars (bytes As ReadOnlySpan(Of Byte), chars As Span(Of Char), flush As Boolean) As Integer

매개 변수

bytes
ReadOnlySpan<Byte>

디코딩할 바이트 범위입니다.

chars
Span<Char>

결과 문자 집합을 쓸 범위입니다.

flush
Boolean

변환 후 디코더의 내부 상태를 지우려면 true이고, 그렇지 않으면 false입니다.

반환

chars 매개 변수가 표시하는 범위에 기록된 실제 문자 수입니다.

설명

개체는 Decoder 에 대한 호출 사이에 상태를 저장합니다 GetChars. 애플리케이션 데이터의 스트림을 사용 하 여 작업이 완료 되는 경우 설정 해야 합니다 flush 매개 변수를 true 상태 정보를 플러시 되도록 해야 합니다. 이 설정을 사용하면 디코더가 데이터 블록 끝에 있는 잘못된 바이트를 무시하고 내부 버퍼를 지웁니다.

결과 문자를 저장해야 하는 GetChars 정확한 범위 크기를 계산하려면 애플리케이션에서 를 사용해야 GetCharCount합니다.

로 설정된 를 사용하여 flushfalse를 호출하는 경우 GetChars 디코더는 내부 버퍼의 데이터 블록 끝에 후행 바이트를 저장하고 다음 디코딩 작업에서 사용합니다. 애플리케이션을 호출 해야 GetCharCount 는 데이터 블록을 호출 하기 바로 직전에 GetChars 동일한 블록의 이전 블록의 모든 후행 바이트 계산에 포함 되도록 합니다.

애플리케이션이 입력 스트림의 여러 세그먼트를 변환할 경우 사용을 고려 합니다 Convert 메서드. GetChars 는 출력 범위가 충분히 크지 않은 경우 예외를 throw하지만 Convert 출력 배열에서 2자 이상을 허용하는 경우 가능한 한 많은 공간을 채우고 읽은 바이트 및 문자를 반환합니다. 더 많은 주석은 Encoding.GetChars 항목도 참조하세요.

적용 대상

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

중요

이 API는 CLS 규격이 아닙니다.

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

public:
 virtual int GetChars(System::Byte* bytes, int byteCount, char* chars, int charCount, bool flush);
[System.CLSCompliant(false)]
public virtual int GetChars (byte* bytes, int byteCount, char* chars, int charCount, bool flush);
[System.CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(false)]
public virtual int GetChars (byte* bytes, int byteCount, char* chars, int charCount, bool flush);
[System.CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(false)]
[System.Security.SecurityCritical]
public virtual int GetChars (byte* bytes, int byteCount, char* chars, int charCount, bool flush);
[<System.CLSCompliant(false)>]
abstract member GetChars : nativeptr<byte> * int * nativeptr<char> * int * bool -> int
override this.GetChars : nativeptr<byte> * int * nativeptr<char> * int * bool -> int
[<System.CLSCompliant(false)>]
[<System.Runtime.InteropServices.ComVisible(false)>]
abstract member GetChars : nativeptr<byte> * int * nativeptr<char> * int * bool -> int
override this.GetChars : nativeptr<byte> * int * nativeptr<char> * int * bool -> int
[<System.CLSCompliant(false)>]
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Security.SecurityCritical>]
abstract member GetChars : nativeptr<byte> * int * nativeptr<char> * int * bool -> int
override this.GetChars : nativeptr<byte> * int * nativeptr<char> * int * bool -> int

매개 변수

bytes
Byte*

디코딩할 첫 번째 바이트를 가리키는 포인터입니다.

byteCount
Int32

디코딩할 바이트 수입니다.

chars
Char*

결과 문자 집합을 쓰기 시작할 위치를 가리키는 포인터입니다.

charCount
Int32

쓸 최대 문자 수입니다.

flush
Boolean

변환 후 디코더의 내부 상태를 지우려면 true이고, 그렇지 않으면 false입니다.

반환

chars 매개 변수가 가리키는 위치에 쓴 실제 문자 수입니다.

특성

예외

bytesnull(Nothing)입니다.

또는

charsnull(Nothing)입니다.

byteCount 또는 charCount가 0보다 작습니다.

charCount가 결과 문자 수보다 작은 경우

대체가 발생했습니다(자세한 내용은 .NET의 문자 인코딩 참조).

FallbackDecoderExceptionFallback로 설정됩니다.

설명

개체는 Decoder 에 대한 호출 사이에 상태를 저장합니다 GetChars. 애플리케이션 데이터의 스트림을 사용 하 여 작업이 완료 되는 경우 설정 해야 합니다 flush 매개 변수를 true 상태 정보를 플러시 되도록 해야 합니다. 이 설정을 사용하면 디코더가 데이터 블록 끝에 있는 잘못된 바이트를 무시하고 내부 버퍼를 지웁니다.

정확한 버퍼 크기를 계산 하려면 GetChars 필요한 결과 문자를 저장 하려면 애플리케이션을 사용할지 GetCharCount합니다.

로 설정된 를 사용하여 flushfalse를 호출하는 경우 GetChars 디코더는 내부 버퍼의 데이터 블록 끝에 후행 바이트를 저장하고 다음 디코딩 작업에서 사용합니다. 애플리케이션을 호출 해야 GetCharCount 는 데이터 블록을 호출 하기 바로 직전에 GetChars 동일한 블록의 이전 블록의 모든 후행 바이트 계산에 포함 되도록 합니다.

애플리케이션이 입력 스트림의 여러 세그먼트를 변환할 경우 사용을 고려 합니다 Convert 메서드. GetChars 출력 버퍼가 충분히 크지는 않지만 Convert 가능한 한 많은 공간을 채우고 출력 배열에서 두 개 이상의 문자를 허용하는 경우 읽기 및 문자가 기록된 바이트를 반환하는 경우 예외가 throw됩니다. 더 많은 주석은 Encoding.GetChars 항목도 참조하세요.

추가 정보

적용 대상

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

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

public:
 abstract int GetChars(cli::array <System::Byte> ^ bytes, int byteIndex, int byteCount, cli::array <char> ^ chars, int charIndex);
public abstract int GetChars (byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex);
abstract member GetChars : byte[] * int * int * char[] * int -> int
Public MustOverride Function GetChars (bytes As Byte(), byteIndex As Integer, byteCount As Integer, chars As Char(), charIndex As Integer) As Integer

매개 변수

bytes
Byte[]

디코딩할 바이트 시퀀스를 포함하는 바이트 배열입니다.

byteIndex
Int32

디코딩할 첫 번째 바이트의 인덱스입니다.

byteCount
Int32

디코딩할 바이트 수입니다.

chars
Char[]

결과 문자 집합을 포함할 문자 배열입니다.

charIndex
Int32

결과 문자 집합을 쓰기 시작할 인덱스입니다.

반환

chars에 쓴 실제 문자 수입니다.

예외

bytesnull(Nothing)입니다.

또는

charsnull(Nothing)입니다.

byteIndex, byteCount 또는 charIndex가 0보다 작은 경우

또는

byteindexbyteCountbytes에서 올바른 범위를 나타내지 않습니다.

또는

charIndexchars의 유효한 인덱스가 아닌 경우

chars의 용량(charIndex ~ 배열 끝)이 부족해서 결과 문자를 수용할 수 없는 경우

대체가 발생했습니다(자세한 내용은 .NET의 문자 인코딩 참조).

FallbackDecoderExceptionFallback로 설정됩니다.

예제

다음 예제에서는 바이트 배열의 요소 범위를 디코딩하고 유니코드 문자 배열에 저장하는 방법을 보여 줍니다. 메서드는 GetCharCount 배열 bytes에 디코딩된 요소를 저장하는 데 필요한 문자 수를 계산하는 데 사용됩니다. 메서드는 GetChars 바이트 배열에서 지정된 요소를 디코딩하고 새 문자 배열에 저장합니다.

using namespace System;
using namespace System::Text;
using namespace System::Collections;
int main()
{
   array<Char>^chars;
   array<Byte>^bytes = {85,0,110,0,105,0,99,0,111,0,100,0,101,0};
   Decoder^ uniDecoder = Encoding::Unicode->GetDecoder();
   int charCount = uniDecoder->GetCharCount( bytes, 0, bytes->Length );
   chars = gcnew array<Char>(charCount);
   int charsDecodedCount = uniDecoder->GetChars( bytes, 0, bytes->Length, chars, 0 );
   Console::WriteLine( "{0} characters used to decode bytes.", charsDecodedCount );
   Console::Write( "Decoded chars: " );
   IEnumerator^ myEnum = chars->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      Char c = safe_cast<Char>(myEnum->Current);
      Console::Write( "[{0}]", c.ToString() );
   }

   Console::WriteLine();
}

/* This code example produces the following output.

7 characters used to decode bytes.
Decoded chars: [U][n][i][c][o][d][e]

*/
using System;
using System.Text;

class UnicodeEncodingExample {
    public static void Main() {
        Char[] chars;
        Byte[] bytes = new Byte[] {
            85, 0, 110, 0, 105, 0, 99, 0, 111, 0, 100, 0, 101, 0
        };

        Decoder uniDecoder = Encoding.Unicode.GetDecoder();

        int charCount = uniDecoder.GetCharCount(bytes, 0, bytes.Length);
        chars = new Char[charCount];
        int charsDecodedCount = uniDecoder.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();
    }
}

/* This code example produces the following output.

7 characters used to decode bytes.
Decoded chars: [U][n][i][c][o][d][e]

*/
Imports System.Text

Class UnicodeEncodingExample
    
    Public Shared Sub Main()
        Dim chars() As Char
        Dim bytes() As Byte = { _
            85, 0, 110, 0, 105, 0, 99, 0, 111, 0, 100, 0, 101, 0 _
        }
        
        Dim uniDecoder As Decoder = Encoding.Unicode.GetDecoder()
        
        Dim charCount As Integer = uniDecoder.GetCharCount(bytes, 0, bytes.Length)
        chars = New Char(charCount - 1) {}
        Dim charsDecodedCount As Integer = _
            uniDecoder.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

'This code example produces the following output.
'
'7 characters used to decode bytes.
'Decoded chars: [U][n][i][c][o][d][e]
'

설명

개체는 Decoder 에 대한 호출 사이에 상태를 저장합니다 GetChars. 애플리케이션 데이터의 스트림을 사용 하 여 작업이 완료 되는 경우 설정 해야 합니다 flush 매개 변수를 true 상태 정보를 플러시 되도록 해야 합니다. 이 설정을 사용하면 디코더가 데이터 블록 끝에 있는 잘못된 바이트를 무시하고 내부 버퍼를 지웁니다.

정확한 배열 크기를 계산 하려면 GetChars 필요한 결과 문자를 저장 하려면 애플리케이션을 사용할지 GetCharCount합니다.

로 설정된 를 사용하여 flushfalse를 호출하는 경우 GetChars 디코더는 내부 버퍼의 데이터 블록 끝에 후행 바이트를 저장하고 다음 디코딩 작업에서 사용합니다. 애플리케이션을 호출 해야 GetCharCount 는 데이터 블록을 호출 하기 바로 직전에 GetChars 동일한 블록의 이전 블록의 모든 후행 바이트 계산에 포함 되도록 합니다.

애플리케이션이 입력 스트림의 여러 세그먼트를 변환할 경우 사용을 고려 합니다 Convert 메서드. GetChars 출력 버퍼가 충분히 크지는 않지만 Convert 가능한 한 많은 공간을 채우고 출력 배열에서 두 개 이상의 문자를 허용하는 경우 읽기 및 문자가 기록된 바이트를 반환하는 경우 예외가 throw됩니다. 더 많은 주석은 Encoding.GetChars 항목도 참조하세요.

추가 정보

적용 대상

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

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

public:
 virtual int GetChars(cli::array <System::Byte> ^ bytes, int byteIndex, int byteCount, cli::array <char> ^ chars, int charIndex, bool flush);
public virtual int GetChars (byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex, bool flush);
abstract member GetChars : byte[] * int * int * char[] * int * bool -> int
override this.GetChars : byte[] * int * int * char[] * int * bool -> int
Public Overridable Function GetChars (bytes As Byte(), byteIndex As Integer, byteCount As Integer, chars As Char(), charIndex As Integer, flush As Boolean) As Integer

매개 변수

bytes
Byte[]

디코딩할 바이트 시퀀스를 포함하는 바이트 배열입니다.

byteIndex
Int32

디코딩할 첫 번째 바이트의 인덱스입니다.

byteCount
Int32

디코딩할 바이트 수입니다.

chars
Char[]

결과 문자 집합을 포함할 문자 배열입니다.

charIndex
Int32

결과 문자 집합을 쓰기 시작할 인덱스입니다.

flush
Boolean

변환 후 디코더의 내부 상태를 지우려면 true이고, 그렇지 않으면 false입니다.

반환

chars 매개 변수에 써지는 실제 문자 수입니다.

예외

bytesnull(Nothing)입니다.

또는

charsnull(Nothing)입니다.

byteIndex, byteCount 또는 charIndex가 0보다 작은 경우

또는

byteindexbyteCountbytes에서 올바른 범위를 나타내지 않습니다.

또는

charIndexchars의 유효한 인덱스가 아닌 경우

chars의 용량(charIndex ~ 배열 끝)이 부족해서 결과 문자를 수용할 수 없는 경우

대체가 발생했습니다(자세한 내용은 .NET의 문자 인코딩 참조).

FallbackDecoderExceptionFallback로 설정됩니다.

설명

개체는 에 Decoder 대한 호출 GetChars사이에 상태를 저장합니다. 애플리케이션 데이터의 스트림을 사용 하 여 작업이 완료 되는 경우 설정 해야 합니다 flush 매개 변수를 true 상태 정보를 플러시 되도록 해야 합니다. 이 설정을 사용하면 디코더가 데이터 블록 끝에 있는 잘못된 바이트를 무시하고 내부 버퍼를 지웁니다.

정확한 배열 크기를 계산 하려면 GetChars 필요한 결과 문자를 저장 하려면 애플리케이션을 사용할지 GetCharCount합니다.

로 설정된 를 사용하여 flushfalse를 호출하는 경우 GetChars 디코더는 내부 버퍼의 데이터 블록 끝에 후행 바이트를 저장하고 다음 디코딩 작업에서 사용합니다. 애플리케이션을 호출 해야 GetCharCount 는 데이터 블록을 호출 하기 바로 직전에 GetChars 동일한 블록의 이전 블록의 모든 후행 바이트 계산에 포함 되도록 합니다.

애플리케이션이 입력 스트림의 여러 세그먼트를 변환할 경우 사용을 고려 합니다 Convert 메서드. GetChars 출력 버퍼가 충분히 크지는 않지만 Convert 가능한 한 많은 공간을 채우고 출력 배열에서 두 개 이상의 문자를 허용하는 경우 읽기 및 문자가 기록된 바이트를 반환하는 경우 예외가 throw됩니다. 더 많은 주석은 Encoding.GetChars 토픽을 참조하세요.

추가 정보

적용 대상