UTF7Encoding.GetByteCount 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
문자 집합을 인코딩하여 생성되는 바이트 수를 계산합니다.
오버로드
| Name | Description |
|---|---|
| GetByteCount(String) |
지정된 String 개체의 문자를 인코딩하여 생성되는 바이트 수를 계산합니다. |
| GetByteCount(Char*, Int32) |
지정된 문자 포인터에서 시작하는 문자 집합을 인코딩하여 생성되는 바이트 수를 계산합니다. |
| GetByteCount(Char[], Int32, Int32) |
지정된 문자 배열의 문자 집합을 인코딩하여 생성되는 바이트 수를 계산합니다. |
GetByteCount(String)
- Source:
- UTF7Encoding.cs
- Source:
- UTF7Encoding.cs
- Source:
- UTF7Encoding.cs
- Source:
- UTF7Encoding.cs
- Source:
- UTF7Encoding.cs
지정된 String 개체의 문자를 인코딩하여 생성되는 바이트 수를 계산합니다.
public:
override int GetByteCount(System::String ^ s);
public override int GetByteCount(string s);
[System.Runtime.InteropServices.ComVisible(false)]
public override int GetByteCount(string s);
override this.GetByteCount : string -> int
[<System.Runtime.InteropServices.ComVisible(false)>]
override this.GetByteCount : string -> int
Public Overrides Function GetByteCount (s As String) As Integer
매개 변수
반품
지정된 문자를 인코딩하여 생성된 바이트 수입니다.
- 특성
예외
s는 (null)입니다 Nothing .
결과 바이트 수가 int로 반환될 수 있는 최대 수보다 큽니다.
예제
다음 코드 예제에서는 메서드를 사용하여 GetByteCount 문자 배열을 인코딩하는 데 필요한 바이트 수를 반환하는 방법을 보여 줍니다.
using System;
using System.Text;
class UTF7EncodingExample {
public static void Main() {
// Unicode characters.
Char[] chars = new Char[] {
'\u0023', // #
'\u0025', // %
'\u03a0', // Pi
'\u03a3' // Sigma
};
UTF7Encoding utf7 = new UTF7Encoding();
int byteCount = utf7.GetByteCount(chars, 1, 2);
Console.WriteLine(
"{0} bytes needed to encode characters.", byteCount
);
}
}
Imports System.Text
Imports Microsoft.VisualBasic.Strings
Class UTF7EncodingExample
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 utf7 As New UTF7Encoding()
Dim byteCount As Integer = utf7.GetByteCount(chars, 1, 2)
Console.WriteLine("{0} bytes needed to encode characters.", byteCount)
End Sub
End Class
설명
결과 바이트를 저장해야 하는 GetBytes 정확한 배열 크기를 계산하기 위해 애플리케이션에서 사용합니다 GetByteCount. 최대 배열 크기를 계산하려면 애플리케이션에서 .를 사용해야 GetMaxByteCount합니다. 이 메서드는 GetByteCount 일반적으로 메모리를 더 적게 할당할 수 있지만 메서드는 GetMaxByteCount 일반적으로 더 빠르게 실행됩니다.
추가 정보
적용 대상
GetByteCount(Char*, Int32)
- Source:
- UTF7Encoding.cs
- Source:
- UTF7Encoding.cs
- Source:
- UTF7Encoding.cs
- Source:
- UTF7Encoding.cs
- Source:
- UTF7Encoding.cs
Important
이 API는 CLS 규격이 아닙니다.
지정된 문자 포인터에서 시작하는 문자 집합을 인코딩하여 생성되는 바이트 수를 계산합니다.
public:
override int GetByteCount(char* chars, int count);
[System.CLSCompliant(false)]
[System.Security.SecurityCritical]
public override int GetByteCount(char* chars, int count);
[System.CLSCompliant(false)]
public override int GetByteCount(char* chars, int count);
[System.CLSCompliant(false)]
[System.Runtime.InteropServices.ComVisible(false)]
public override int GetByteCount(char* chars, int count);
[System.CLSCompliant(false)]
[System.Security.SecurityCritical]
[System.Runtime.InteropServices.ComVisible(false)]
public override int GetByteCount(char* chars, int count);
[<System.CLSCompliant(false)>]
[<System.Security.SecurityCritical>]
override this.GetByteCount : nativeptr<char> * int -> int
[<System.CLSCompliant(false)>]
override this.GetByteCount : nativeptr<char> * int -> int
[<System.CLSCompliant(false)>]
[<System.Runtime.InteropServices.ComVisible(false)>]
override this.GetByteCount : nativeptr<char> * int -> int
[<System.CLSCompliant(false)>]
[<System.Security.SecurityCritical>]
[<System.Runtime.InteropServices.ComVisible(false)>]
override this.GetByteCount : nativeptr<char> * int -> int
매개 변수
- chars
- Char*
인코딩할 첫 번째 문자에 대한 포인터입니다.
- count
- Int32
인코딩할 문자 수입니다.
반품
지정된 문자를 인코딩하여 생성된 바이트 수입니다.
- 특성
예외
chars
null(Visual Basic .NET Nothing)입니다.
설명
결과 바이트를 저장해야 하는 GetBytes 정확한 배열 크기를 계산하기 위해 애플리케이션에서 사용합니다 GetByteCount. 최대 배열 크기를 계산하려면 애플리케이션에서 .를 사용해야 GetMaxByteCount합니다. 이 메서드는 GetByteCount 일반적으로 메모리를 더 적게 할당할 수 있지만 메서드는 GetMaxByteCount 일반적으로 더 빠르게 실행됩니다.
추가 정보
적용 대상
GetByteCount(Char[], Int32, Int32)
- Source:
- UTF7Encoding.cs
- Source:
- UTF7Encoding.cs
- Source:
- UTF7Encoding.cs
- Source:
- UTF7Encoding.cs
- Source:
- UTF7Encoding.cs
지정된 문자 배열의 문자 집합을 인코딩하여 생성되는 바이트 수를 계산합니다.
public:
override int GetByteCount(cli::array <char> ^ chars, int index, int count);
public override int GetByteCount(char[] chars, int index, int count);
override this.GetByteCount : char[] * int * int -> int
Public Overrides Function GetByteCount (chars As Char(), index As Integer, count As Integer) As Integer
매개 변수
- chars
- Char[]
인코딩할 문자 집합이 포함된 문자 배열입니다.
- index
- Int32
인코딩할 첫 번째 문자의 인덱스입니다.
- count
- Int32
인코딩할 문자 수입니다.
반품
지정된 문자를 인코딩하여 생성된 바이트 수입니다.
예외
chars는 (null)입니다 Nothing .
index 또는 count 0보다 작습니다.
-또는-
index 에서 count 유효한 범위를 chars나타내지 않습니다.
-또는-
결과 바이트 수가 int로 반환될 수 있는 최대 수보다 큽니다.
예제
다음 코드 예제에서는 메서드를 사용하여 GetByteCount 유니코드 문자 배열을 인코딩하는 데 필요한 바이트 수를 반환하는 방법을 보여 줍니다.
using System;
using System.Text;
class UTF7EncodingExample {
public static void Main() {
// Unicode characters.
Char[] chars = new Char[] {
'\u0023', // #
'\u0025', // %
'\u03a0', // Pi
'\u03a3' // Sigma
};
UTF7Encoding utf7 = new UTF7Encoding();
int byteCount = utf7.GetByteCount(chars, 1, 2);
Console.WriteLine(
"{0} bytes needed to encode characters.", byteCount
);
}
}
Imports System.Text
Imports Microsoft.VisualBasic.Strings
Class UTF7EncodingExample
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 utf7 As New UTF7Encoding()
Dim byteCount As Integer = utf7.GetByteCount(chars, 1, 2)
Console.WriteLine("{0} bytes needed to encode characters.", byteCount)
End Sub
End Class
설명
결과 바이트를 저장하는 데 필요한 GetBytes 정확한 배열 크기를 계산하기 위해 애플리케이션에서 사용합니다 GetByteCount. 최대 배열 크기를 계산하려면 애플리케이션에서 .를 사용해야 GetMaxByteCount합니다. 이 메서드는 GetByteCount 일반적으로 메모리를 더 적게 할당할 수 있지만 메서드는 GetMaxByteCount 일반적으로 더 빠르게 실행됩니다.