UTF7Encoding.GetDecoder メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As UTF7Encoding Dim returnValue As Decoder returnValue = instance.GetDecoder
UTF-7 でエンコードされたバイト シーケンスを Unicode 文字のシーケンスに変換する Decoder。

Decoder.GetChars メソッドは、このクラスの GetChars メソッドと同様の方法で、連続するバイト ブロックを連続する文字ブロックに変換します。ただし、Decoder では、ブロックにまたがるバイト シーケンスを正確にデコードできるように、呼び出し間のステータス情報を維持します。また、Decoder は、データ ブロックの末尾で後続バイトを保持し、その後続バイトを次のデコード操作に使用します。したがって、GetDecoder と GetEncoder は、ネットワーク伝送やファイル操作に役立ちます。これは、ネットワーク伝送やファイル操作では、完全なデータ ストリームではなくデータのブロックを処理することが多いためです。

次のコード例は、GetDecoder メソッドを使用して、UTF-7 でエンコードされたバイトを文字シーケンスに変換するデコーダを取得する方法を示しています。
Imports System Imports System.Text Class UTF7EncodingExample Public Shared Sub Main() Dim chars() As Char Dim bytes() As Byte = {99, 43, 65, 119, 67, 103, 111, 65, 45} Dim utf7Decoder As Decoder = Encoding.UTF7.GetDecoder() Dim charCount As Integer = utf7Decoder.GetCharCount(bytes, 0, bytes.Length) chars = New Char(charCount - 1) {} Dim charsDecodedCount As Integer = utf7Decoder.GetChars(bytes, 0, bytes.Length, 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 'Main End Class 'UTF7EncodingExample
using System; using System.Text; class UTF7EncodingExample { public static void Main() { Char[] chars; Byte[] bytes = new Byte[] { 99, 43, 65, 119, 67, 103, 111, 65, 45 }; Decoder utf7Decoder = Encoding.UTF7.GetDecoder(); int charCount = utf7Decoder.GetCharCount(bytes, 0, bytes.Length); chars = new Char[charCount]; int charsDecodedCount = utf7Decoder.GetChars(bytes, 0, bytes.Length, 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(); } }
using namespace System; using namespace System::Text; using namespace System::Collections; int main() { array<Char>^chars; array<Byte>^bytes = {99,43,65,119,67,103,111,65,45}; Decoder^ utf7Decoder = Encoding::UTF7->GetDecoder(); int charCount = utf7Decoder->GetCharCount( bytes, 0, bytes->Length ); chars = gcnew array<Char>(charCount); int charsDecodedCount = utf7Decoder->GetChars( bytes, 0, bytes->Length, 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(); }
import System.*; import System.Text.*; class UTF7EncodingExample { public static void main(String[] args) { char chars[]; ubyte bytes[] = new ubyte[] { 99, 43, 65, 119, 67, 103, 111, 65, 45 }; Decoder utf7Decoder = Encoding.get_UTF7().GetDecoder(); int charCount = utf7Decoder.GetCharCount(bytes, 0, bytes.length); chars = new char[charCount]; int charsDecodedCount = utf7Decoder.GetChars(bytes, 0, bytes.length, chars, 0); Console.WriteLine("{0} characters used to decode bytes.", String.valueOf(charsDecodedCount)); Console.Write("Decoded chars: "); for(int iCtr = 0; iCtr < chars.length; iCtr++) { char c = chars[iCtr]; Console.Write("[{0}]", String.valueOf(c)); } Console.WriteLine(); } //main } //UTF7EncodingExample

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- UTF7Encoding.GetDecoder メソッドのページへのリンク