Encoder.GetByteCount 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
파생 클래스에서 재정의되는 경우 문자 집합을 인코딩하여 생성되는 바이트 수를 계산합니다.
오버로드
| Name | Description |
|---|---|
| GetByteCount(ReadOnlySpan<Char>, Boolean) |
파생 클래스에서 재정의되는 경우 'chars' 범위의 문자 집합을 인코딩하여 생성된 바이트 수를 계산합니다. 매개 변수는 계산 후 인코더의 내부 상태를 지울지 여부를 나타냅니다. |
| GetByteCount(Char*, Int32, Boolean) |
파생 클래스에서 재정의되는 경우 지정된 문자 포인터에서 시작하는 문자 집합을 인코딩하여 생성되는 바이트 수를 계산합니다. 매개 변수는 계산 후 인코더의 내부 상태를 지울지 여부를 나타냅니다. |
| GetByteCount(Char[], Int32, Int32, Boolean) |
파생 클래스에서 재정의되는 경우 지정된 문자 배열의 문자 집합을 인코딩하여 생성된 바이트 수를 계산합니다. 매개 변수는 계산 후 인코더의 내부 상태를 지울지 여부를 나타냅니다. |
설명
이 메서드는 인코더의 상태에 영향을 주지 않습니다.
결과 바이트를 저장해야 하는 GetBytes 정확한 배열 크기를 계산하려면 애플리케이션에서 .를 사용해야 GetByteCount합니다.
set to로 flushfalse호출되는 경우 GetBytes 인코더는 내부 버퍼의 데이터 블록 끝에 후행 문자를 저장하고 다음 인코딩 작업에서 사용합니다. 애플리케이션은 이전 블록의 후행 문자가 계산에 포함되도록 동일한 블록을 호출하기 직전에 데이터 블록을 호출 GetByteCountGetBytes 해야 합니다.
GetByteCount(ReadOnlySpan<Char>, Boolean)
파생 클래스에서 재정의되는 경우 'chars' 범위의 문자 집합을 인코딩하여 생성된 바이트 수를 계산합니다. 매개 변수는 계산 후 인코더의 내부 상태를 지울지 여부를 나타냅니다.
public:
virtual int GetByteCount(ReadOnlySpan<char> chars, bool flush);
public virtual int GetByteCount(ReadOnlySpan<char> chars, bool flush);
abstract member GetByteCount : ReadOnlySpan<char> * bool -> int
override this.GetByteCount : ReadOnlySpan<char> * bool -> int
Public Overridable Function GetByteCount (chars As ReadOnlySpan(Of Char), flush As Boolean) As Integer
매개 변수
- chars
- ReadOnlySpan<Char>
인코딩할 문자 범위입니다.
- flush
- Boolean
true계산 후 인코더의 내부 상태 지우기를 시뮬레이트합니다. 그렇지 않으면 . false
반품
지정된 문자와 내부 버퍼의 문자를 인코딩하여 생성되는 바이트 수입니다.
적용 대상
GetByteCount(Char*, Int32, Boolean)
Important
이 API는 CLS 규격이 아닙니다.
파생 클래스에서 재정의되는 경우 지정된 문자 포인터에서 시작하는 문자 집합을 인코딩하여 생성되는 바이트 수를 계산합니다. 매개 변수는 계산 후 인코더의 내부 상태를 지울지 여부를 나타냅니다.
public:
virtual int GetByteCount(char* chars, int count, bool flush);
[System.CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(false)]
public virtual int GetByteCount(char* chars, int count, bool flush);
[System.CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(false)]
[System.Security.SecurityCritical]
public virtual int GetByteCount(char* chars, int count, bool flush);
[System.CLSCompliant(false)]
public virtual int GetByteCount(char* chars, int count, bool flush);
[<System.CLSCompliant(false)>]
[<System.Runtime.InteropServices.ComVisible(false)>]
abstract member GetByteCount : nativeptr<char> * int * bool -> int
override this.GetByteCount : nativeptr<char> * int * bool -> int
[<System.CLSCompliant(false)>]
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Security.SecurityCritical>]
abstract member GetByteCount : nativeptr<char> * int * bool -> int
override this.GetByteCount : nativeptr<char> * int * bool -> int
[<System.CLSCompliant(false)>]
abstract member GetByteCount : nativeptr<char> * int * bool -> int
override this.GetByteCount : nativeptr<char> * int * bool -> int
매개 변수
- chars
- Char*
인코딩할 첫 번째 문자에 대한 포인터입니다.
- count
- Int32
인코딩할 문자 수입니다.
- flush
- Boolean
true계산 후 인코더의 내부 상태 지우기를 시뮬레이트합니다. 그렇지 않으면 . false
반품
지정된 문자와 내부 버퍼의 문자를 인코딩하여 생성되는 바이트 수입니다.
- 특성
예외
chars
null(Visual Basic .NET Nothing)입니다.
count가 0보다 작습니다.
추가 정보
적용 대상
GetByteCount(Char[], Int32, Int32, Boolean)
파생 클래스에서 재정의되는 경우 지정된 문자 배열의 문자 집합을 인코딩하여 생성된 바이트 수를 계산합니다. 매개 변수는 계산 후 인코더의 내부 상태를 지울지 여부를 나타냅니다.
public:
abstract int GetByteCount(cli::array <char> ^ chars, int index, int count, bool flush);
public abstract int GetByteCount(char[] chars, int index, int count, bool flush);
abstract member GetByteCount : char[] * int * int * bool -> int
Public MustOverride Function GetByteCount (chars As Char(), index As Integer, count As Integer, flush As Boolean) As Integer
매개 변수
- chars
- Char[]
인코딩할 문자 집합이 포함된 문자 배열입니다.
- index
- Int32
인코딩할 첫 번째 문자의 인덱스입니다.
- count
- Int32
인코딩할 문자 수입니다.
- flush
- Boolean
true계산 후 인코더의 내부 상태 지우기를 시뮬레이트합니다. 그렇지 않으면 . false
반품
지정된 문자와 내부 버퍼의 문자를 인코딩하여 생성되는 바이트 수입니다.
예외
chars은 null입니다.
예제
다음 코드 예제에서는 메서드를 사용하여 GetByteCount 유니코드 Encoder를 사용하여 문자 배열을 인코딩하는 데 필요한 바이트 수를 반환하는 방법을 보여 줍니다.
using System;
using System.Text;
class EncoderExample {
public static void Main() {
// Unicode characters.
Char[] chars = new Char[] {
'\u0023', // #
'\u0025', // %
'\u03a0', // Pi
'\u03a3' // Sigma
};
Encoder uniEncoder = Encoding.Unicode.GetEncoder();
int byteCount = uniEncoder.GetByteCount(chars, 0, chars.Length, true);
Console.WriteLine(
"{0} bytes needed to encode characters.", byteCount
);
}
}
/* This example produces the following output.
8 bytes needed to encode characters.
*/
Imports System.Text
Imports Microsoft.VisualBasic.Strings
Class EncoderExample
Public Shared Sub Main()
' Unicode characters.
' ChrW(35) = #
' ChrW(37) = %
' ChrW(928) = Pi
' ChrW(931) = Sigma
Dim chars() As Char = {ChrW(35), ChrW(37), ChrW(928), ChrW(931)}
Dim uniEncoder As Encoder = Encoding.Unicode.GetEncoder()
Dim byteCount As Integer = _
uniEncoder.GetByteCount(chars, 0, chars.Length, True)
Console.WriteLine("{0} bytes needed to encode characters.", byteCount)
End Sub
End Class
'
'This example produces the following output.
'
'8 bytes needed to encode characters.
'