Decoder クラスとは? わかりやすく解説

Decoder クラス

エンコード済みバイト シーケンス文字セット変換します

名前空間: System.Text
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public MustInherit Class
 Decoder
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public abstract class Decoder
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public ref class Decoder abstract
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public abstract class Decoder
SerializableAttribute 
ComVisibleAttribute(true) 
public abstract class Decoder
解説解説

エンコーディングは、文字セットバイト シーケンス変換するプロセスです。デコードはその逆になりますエンコードされたバイト シーケンス文字セット変換するプロセスです。

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

GetCharCount メソッドは、バイト シーケンスデコードした結果生成される文字数判断しGetChars メソッドは、実際にデコード実行します

このクラス実装インスタンス取得するには、Encoding 実装GetDecoder メソッド使用します

バージョン考慮事項

継承時の注意 このクラスから継承する場合は、すべてのメンバオーバーライドする必要があります

使用例使用例

Decoder使用して2 つ異なバイト配列1 つ文字配列変換するコード例次に示します文字バイトいずれか配列またがってます。これは、ストリーム読み取るときの System.IO.StreamReader の内部処理似てます。

Imports System
Imports System.Text

Public Class dec
    
    Public Shared Sub Main()
        ' These bytes in UTF-8 correspond to 3 different Unicode
        ' characters: space (U+0020), # (U+0023), and the biohazard
        ' symbol (U+2623).  Note the biohazard symbol requires 3 bytes
        ' in UTF-8 (hexadecimal e2, 98, a3).  Decoders store state across
        ' multiple calls to GetChars, handling the case when one char
        ' is in multiple byte arrays.
        Dim bytes1 As Byte()
 =  {&H20, &H23, &HE2}
        Dim bytes2 As Byte()
 =  {&H98, &HA3}
        Dim chars(3) As Char
        
        Dim d As Decoder = Encoding.UTF8.GetDecoder()
        Dim charLen As Integer
 = d.GetChars(bytes1, 0, bytes1.Length, chars, 0)
        ' The value of charLen should be 2 now.
        charLen += d.GetChars(bytes2, 0, bytes2.Length, chars, charLen)
        Dim c As Char
        For Each c In  chars
            Console.Write("U+{0:X4}  ", Convert.ToUInt16(c)
 )
        Next c
    End Sub
End Class
using System;
using System.Text;
public class dec
{
    public static void Main()
    {
        // These bytes in UTF-8 correspond to 3 different Unicode
        // characters: space (U+0020), # (U+0023), and the biohazard
        // symbol (U+2623).  Note the biohazard symbol requires 3 bytes
        // in UTF-8 (hexadecimal e2, 98, a3).  Decoders store state
 across
        // multiple calls to GetChars, handling the case when one char
        // is in multiple byte arrays.
        byte[] bytes1 = { 0x20, 0x23, 0xe2 };
        byte[] bytes2 = { 0x98, 0xa3 };
        char[] chars = new char[3];

        Decoder d = Encoding.UTF8.GetDecoder();
        int charLen = d.GetChars(bytes1, 0, bytes1.Length, chars,
 0);
        // The value of charLen should be 2 now.
        charLen += d.GetChars(bytes2, 0, bytes2.Length, chars, charLen);
        foreach(char c in
 chars)
            Console.Write("U+{0:X4}  ", (ushort)c);
    }
}
using namespace System;
using namespace System::Text;
int main()
{
   
   // These bytes in UTF-8 correspond to 3 different Unicode
   // characters: space (U+0020), # (U+0023), and the biohazard
   // symbol (U+2623).  Note the biohazard symbol requires 3 bytes
   // in UTF-8 (hexadecimal e2, 98, a3).  Decoders store state across
   // multiple calls to GetChars, handling the case when one char
   // is in multiple byte arrays.
   array<Byte>^bytes1 = {0x20,0x23,0xe2};
   array<Byte>^bytes2 = {0x98,0xa3};
   array<Char>^chars = gcnew array<Char>(3);
   Decoder^ d = Encoding::UTF8->GetDecoder();
   int charLen = d->GetChars( bytes1, 0, bytes1->Length,
 chars, 0 );
   
   // The value of charLen should be 2 now.
   charLen += d->GetChars( bytes2, 0, bytes2->Length, chars, charLen );
   for ( UInt16 index(0); index < chars->Length; ++index
 )
   {
      Console::Write( "U+{0:X4}  ", static_cast<UInt16>(chars[ index
 ]) );

   }
}

import System.*;
import System.Text.*;

public class Dec
{
    public static void main(String[]
 args)
    {
        // These bytes in UTF-8 correspond to 3 different Unicode
        // characters: space (U+0020), # (U+0023), and the biohazard
        // symbol (U+2623).  Note the biohazard symbol requires 3 bytes
        // in UTF-8 (hexadecimal e2, 98, a3).  Decoders store state
 across
        // multiple calls to GetChars, handling the case when one char
        // is in multiple byte arrays.
        ubyte bytes1[] =  { 0x20, 0x23, 0xE2 };
        ubyte bytes2[] =  { 0x98, 0xA3 };
        char chars[] = new char[3];
        
        Decoder d = Encoding.get_UTF8().GetDecoder();
        int charLen = d.GetChars(bytes1, 0, bytes1.length, chars,
 0);
        
        // The value of charLen should be 2 now.
        charLen += d.GetChars(bytes2, 0, bytes2.length, chars, charLen);

        for (int iCtr = 0; iCtr < chars.length;
 iCtr++) {
            char c = chars[iCtr];
            Console.Write("U+{0}  ",((Int16)c).ToString("X4"));
        }
    } //main
} //Dec
継承階層継承階層
System.Object
  System.Text.Decoder
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からDecoder クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からDecoder クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からDecoder クラス を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Decoder クラス」の関連用語

Decoder クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Decoder クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS