指定したバイト数をデコードして得られる、最大文字数を計算します。
Overrides Public Function GetMaxCharCount( _
ByVal byteCount As Integer _) As Integer
[C#]
public override int GetMaxCharCount(intbyteCount);
[C++]
public: int GetMaxCharCount(intbyteCount);
[JScript]
public override function GetMaxCharCount(
byteCount : int) : int;
パラメータ
- byteCount
デコードするバイト数。
戻り値
byteCount のバイト数のバイトをデコードした結果の文字数の最大値。
解説
デコードされたバイトを格納するために GetChars メソッドによって要求された配列サイズを正確に計算するには GetCharCount を使用し、その最大値を計算するには GetMaxCharCount を使用します。
使用例
[Visual Basic, C#, C++] 変数 byteCount
に格納されている指定したバイト数をデコードし、その結果の最大文字数を GetMaxCharCount メソッドを使用して返す方法を次の例に示します。
Imports System
Imports System.Text
Class UTF7EncodingExample
Public Shared Sub Main()
Dim utf7 As New UTF7Encoding()
Dim byteCount As Integer = 8
Dim maxCharCount As Integer = utf7.GetMaxCharCount(byteCount)
Console.WriteLine( _
"Maximum of {0} characters needed to decode {1} bytes.", _
maxCharCount, _
byteCount _
)
End Sub 'Main
End Class 'UTF7EncodingExample
[C#]
using System;
using System.Text;
class UTF7EncodingExample {
public static void Main() {
UTF7Encoding utf7 = new UTF7Encoding();
int byteCount = 8;
int maxCharCount = utf7.GetMaxCharCount(byteCount);
Console.WriteLine(
"Maximum of {0} characters needed to decode {1} bytes.",
maxCharCount,
byteCount
);
}
}
[C++]
#using <mscorlib.dll>
using namespace System;
using namespace System::Text;
int main()
{
UTF7Encoding* utf7 = new UTF7Encoding();
int byteCount = 8;
int maxCharCount = utf7 -> GetMaxCharCount(byteCount);
Console::WriteLine(S"Maximum of {0} characters needed to decode {1} bytes.",
__box(maxCharCount),
__box(byteCount));
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
参照
UTF7Encoding クラス | UTF7Encoding メンバ | System.Text 名前空間 | GetChars | GetChars