UTF7Encoding.GetChars 메서드

정의

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

오버로드

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

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

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

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

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

Source:
UTF7Encoding.cs
Source:
UTF7Encoding.cs
Source:
UTF7Encoding.cs
Source:
UTF7Encoding.cs
Source:
UTF7Encoding.cs

Important

이 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

쓸 최대 문자 수입니다.

반품

로 표시된 위치에 기록된 chars실제 문자 수입니다.

특성

예외

bytes는 (null)입니다 Nothing .

-또는-

chars는 (null)입니다 Nothing .

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

charCount 가 결과 문자 수보다 작습니다.

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

-그리고-

DecoderFallbackDecoderExceptionFallback로 설정됩니다.

설명

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

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

메모

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

추가 정보

적용 대상

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

Source:
UTF7Encoding.cs
Source:
UTF7Encoding.cs
Source:
UTF7Encoding.cs
Source:
UTF7Encoding.cs
Source:
UTF7Encoding.cs

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

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

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

반품

로 작성된 실제 문자 수입니다 chars.

예외

bytes는 (null)입니다 Nothing .

-또는-

chars는 (null)입니다 Nothing .

byteIndex 또는 byteCountcharIndex 0보다 작습니다.

-또는-

byteIndex 에서 byteCount 유효한 범위를 bytes나타내지 않습니다.

-또는-

charIndex에서 유효한 인덱스가 아닌 경우 chars

chars 에는 결과 문자를 수용할 수 있는 충분한 용량 charIndex 이 없습니다.

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

-그리고-

DecoderFallbackDecoderExceptionFallback로 설정됩니다.

예제

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

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

설명

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

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

메모

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

추가 정보

적용 대상