UTF7Encoding.GetChars 메서드

정의

바이트 시퀀스를 문자 집합으로 디코딩합니다.

오버로드

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

지정한 바이트 포인터에서 시작하는 바이트 시퀀스를 지정한 문자 포인터에서 시작하여 저장되는 문자 집합으로 디코딩합니다.

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

지정한 바이트 배열의 바이트 시퀀스를 지정한 문자 배열로 디코딩합니다.

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

중요

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

지정한 바이트 포인터에서 시작하는 바이트 시퀀스를 지정한 문자 포인터에서 시작하여 저장되는 문자 집합으로 디코딩합니다.

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

매개 변수

bytes
Byte*

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

byteCount
Int32

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

chars
Char*

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

charCount
Int32

쓸 최대 문자 수입니다.

반환

Int32

chars가 가리키는 위치에 써지는 실제 문자 수입니다.

특성

예외

bytesnull(Nothing)입니다.

또는 charsnull(Nothing)입니다.

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

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

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

설명

결과 문자를 GetCharCount저장하는 데 필요한 GetChars 정확한 배열 크기를 계산하려면 . 최대 배열 크기를 계산 하려면 애플리케이션을 사용할지 GetMaxCharCount합니다. 메서드는 일반적으로 더 GetCharCount 많은 메모리를 할당 하는 것을 허용 하지만 GetMaxCharCount 메서드는 일반적으로 더 빠르게 실행 됩니다.

스트림에서 읽은 데이터와 같이 변환할 데이터는 순차적 블록에서만 사용할 수 있습니다. 이 경우 애플리케이션 데이터의 양이 너무 커서 작은 블록으로 나눌 필요가 있는 경우를 사용 해야 합니다 Decoder 또는 Encoder 제공한를 GetDecoder 메서드 또는 GetEncoder 메서드를 각각.

참고

UTF7Encoding 오류 검색을 제공하지 않습니다. 잘못된 바이트가 발견되면 UTF7Encoding 일반적으로 잘못된 바이트를 내보낸다. 바이트가 16진수 0x7F 16진수보다 크면 바이트 값이 유니코드 문자로 0으로 확장되고 결과가 배열에 chars 저장되고 모든 시퀀스가 종료됩니다. 예를 들어 인코딩할 바이트가 16진수 0x81 경우 결과 문자는 U+0081입니다. 보안상의 이유로 애플리케이션은 사용 하는 좋습니다 UTF8Encoding, UnicodeEncoding, 또는 UTF32Encoding 오류 검색을 사용 하도록 설정 합니다.

추가 정보

적용 대상

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

지정한 바이트 배열의 바이트 시퀀스를 지정한 문자 배열로 디코딩합니다.

public:
 override int GetChars(cli::array <System::Byte> ^ bytes, int byteIndex, int byteCount, cli::array <char> ^ chars, int charIndex);
public override int GetChars (byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex);
override this.GetChars : byte[] * int * int * char[] * int -> int
Public Overrides 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

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

반환

Int32

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

예외

bytesnull(Nothing)입니다.

또는 charsnull(Nothing)입니다.

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

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

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

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

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

예제

다음 코드 예제에서는 메서드를 사용하여 GetChars 바이트 배열의 요소 범위를 디코딩하고 결과를 문자 배열에 저장하는 방법을 보여 줍니다.

using namespace System;
using namespace System::Text;
using namespace System::Collections;
int main()
{
   array<Char>^chars;
   array<Byte>^bytes = {85,84,70,55,32,69,110,99,111,100,105,110,103,32,69,120,97,109,112,108,101};
   UTF7Encoding^ utf7 = gcnew UTF7Encoding;
   int charCount = utf7->GetCharCount( bytes, 2, 8 );
   chars = gcnew array<Char>(charCount);
   int charsDecodedCount = utf7->GetChars( bytes, 2, 8, 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();
}
using System;
using System.Text;

class UTF7EncodingExample {
    public static void Main() {
        Char[] chars;
        Byte[] bytes = new Byte[] {
             85,  84,  70,  55,  32,  69, 110,
             99, 111, 100, 105, 110, 103,  32,
             69, 120,  97, 109, 112, 108, 101
        };

        UTF7Encoding utf7 = new UTF7Encoding();

        int charCount = utf7.GetCharCount(bytes, 2, 8);
        chars = new Char[charCount];
        int charsDecodedCount = utf7.GetChars(bytes, 2, 8, 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 = { _
            85,  84,  70,  55,  32,  69, 110, _
            99, 111, 100, 105, 110, 103,  32, _
            69, 120,  97, 109, 112, 108, 101 _
        }
        
        Dim utf7 As New UTF7Encoding()
        
        Dim charCount As Integer = utf7.GetCharCount(bytes, 2, 8)
        chars = New Char(charCount - 1) {}
        Dim charsDecodedCount As Integer = utf7.GetChars(bytes, 2, 8, 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

설명

결과 문자를 GetCharCount저장하는 데 필요한 GetChars 정확한 배열 크기를 계산하려면 . 최대 배열 크기를 계산 하려면 애플리케이션을 사용할지 GetMaxCharCount합니다. 메서드는 일반적으로 더 GetCharCount 많은 메모리를 할당 하는 것을 허용 하지만 GetMaxCharCount 메서드는 일반적으로 더 빠르게 실행 됩니다.

스트림에서 읽은 데이터와 같이 변환할 데이터는 순차적 블록에서만 사용할 수 있습니다. 이 경우 애플리케이션 데이터의 양이 너무 커서 작은 블록으로 나눌 필요가 있는 경우를 사용 해야 합니다 Decoder 또는 Encoder 제공한를 GetDecoder 메서드 또는 GetEncoder 메서드를 각각.

참고

UTF7Encoding 오류 검색을 제공하지 않습니다. 잘못된 바이트가 발견되면 UTF7Encoding 일반적으로 잘못된 바이트를 내보낸다. 바이트가 16진수 0x7F 16진수보다 크면 바이트 값이 유니코드 문자로 0으로 확장되고 결과가 배열에 chars 저장되고 모든 시퀀스가 종료됩니다. 예를 들어 인코딩할 바이트가 16진수 0x81 경우 결과 문자는 U+0081입니다. 보안상의 이유로 애플리케이션은 사용 하는 좋습니다 UTF8Encoding, UnicodeEncoding, 또는 UTF32Encoding 오류 검색을 사용 하도록 설정 합니다.

추가 정보

적용 대상