UTF32Encoding.GetPreamble メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > UTF32Encoding.GetPreamble メソッドの意味・解説 

UTF32Encoding.GetPreamble メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

このインスタンスコンストラクタバイト順マーク付加するよう指定した場合に、UTF-32 形式エンコードされた Unicode バイト順マーク返します

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

解説解説

プリアンブルエンコード済みストリーム前に付加されていると、使用されているエンコーディング形式デコーダ識別するのに役立ちます

エンコーダでは、最上位バイト先頭配置されるビッグ エンディアン バイト順、または最下位バイト先頭配置されるリトル エンディアン バイト順が使用されます。たとえば、Latin大文字 A (コード ポイント U+0041) は次のように 16 進数シリアル化されます

UTF32Encoding は、オプションプリアンブル提供しますプリアンブルは、エンコーディング プロセス得られたバイト シーケンス先頭付加できるバイト配列です。プリアンブルバイト順マーク (コード ポイント U+FEFF) が含まれる場合デコーダバイト順および変換形式 (UTF) を判断できますUnicode バイト順マークは、次のように 16 進数シリアル化されます

通常ネイティブバイト順で Unicode 文字格納した方が効率的です。たとえば、Intelコンピュータなど、リトル エンディアンプラットフォームでは、リトル エンディアンバイト順を使用した方が効率的です。

バイト順とバイト順マーク詳細については、www.unicode.org の「Unicode Standard」を参照してください

注意に関するメモ注意

エンコード済みバイト正しくデコードするには、エンコード済みバイト前にプリアンブル付加します

使用例使用例

次のコード例は、さまざまな UTF32Encoding インスタンスバイト順マーク取得して表示します

Imports System
Imports System.Text

Public Class SamplesUTF32Encoding   

   Public Shared Sub Main()

      ' Create instances of UTF32Encoding, with the byte order mark
 and without.
      Dim u32LeNone As New
 UTF32Encoding()
      Dim u32BeNone As New
 UTF32Encoding(True, False)
      Dim u32LeBom As New
 UTF32Encoding(False, True)
      Dim u32BeBom As New
 UTF32Encoding(True, True)

      ' Display the preamble for each instance.
      PrintHexBytes(u32LeNone.GetPreamble())
      PrintHexBytes(u32BeNone.GetPreamble())
      PrintHexBytes(u32LeBom.GetPreamble())
      PrintHexBytes(u32BeBom.GetPreamble())

   End Sub 'Main


   Public Shared Sub PrintHexBytes(bytes()
 As Byte)

      If bytes Is Nothing
 OrElse bytes.Length = 0 Then
         Console.WriteLine("<none>")
      Else
         Dim i As Integer
         For i = 0 To bytes.Length - 1
            Console.Write("{0:X2} ", bytes(i))
         Next i
         Console.WriteLine()
      End If

   End Sub 'PrintHexBytes 

End Class 'SamplesUTF32Encoding


'This code produces the following output.
'
'&lt;none&gt;
'&lt;none&gt;
'FF FE 00 00
'00 00 FE FF

using System;
using System.Text;

public class SamplesUTF32Encoding  {

   public static void Main()
  {

      // Create instances of UTF32Encoding, with the byte order mark
 and without.
      UTF32Encoding u32LeNone = new UTF32Encoding();
      UTF32Encoding u32BeNone = new UTF32Encoding( true,
 false );
      UTF32Encoding u32LeBom  = new UTF32Encoding( false,
 true );
      UTF32Encoding u32BeBom  = new UTF32Encoding( true,
 true );

      // Display the preamble for each instance.
      PrintHexBytes( u32LeNone.GetPreamble() );
      PrintHexBytes( u32BeNone.GetPreamble() );
      PrintHexBytes( u32LeBom.GetPreamble() );
      PrintHexBytes( u32BeBom.GetPreamble() );

   }

   public static void PrintHexBytes(
 byte[] bytes )  {

      if (( bytes == null ) || ( bytes.Length
 == 0 ))
         Console.WriteLine( "<none>" );
      else  {
         for ( int i = 0; i < bytes.Length;
 i++ )
            Console.Write( "{0:X2} ", bytes[i] );
         Console.WriteLine();
      }

   }

}


/* 
This code produces the following output.

&lt;none&gt;
&lt;none&gt;
FF FE 00 00
00 00 FE FF

*/

using namespace System;
using namespace System::Text;
void PrintHexBytes( array<Byte>^bytes );
int main()
{
   
   // Create instances of UTF32Encoding, with the byte order mark and
 without.
   UTF32Encoding ^ u32LeNone = gcnew UTF32Encoding;
   UTF32Encoding ^ u32BeNone = gcnew UTF32Encoding( true,false
 );
   UTF32Encoding ^ u32LeBom = gcnew UTF32Encoding( false,true
 );
   UTF32Encoding ^ u32BeBom = gcnew UTF32Encoding( true,true
 );
   
   // Display the preamble for each instance.
   PrintHexBytes( u32LeNone->GetPreamble() );
   PrintHexBytes( u32BeNone->GetPreamble() );
   PrintHexBytes( u32LeBom->GetPreamble() );
   PrintHexBytes( u32BeBom->GetPreamble() );
}

void PrintHexBytes( array<Byte>^bytes )
{
   if ( (bytes == nullptr) || (bytes->Length == 0) )
      Console::WriteLine( "<none>" );
   else
   {
      for ( int i = 0; i < bytes->Length;
 i++ )
         Console::Write( "{0:X2} ", bytes[ i ] );
      Console::WriteLine();
   }
}

/* 
This code produces the following output.

&lt;none&gt;
&lt;none&gt;
FF FE 00 00
00 00 FE FF

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

public class SamplesUTF32Encoding
{
    public static void main(String[]
 args)
    {
        // Create instances of UTF32Encoding, with the byte 
        // order mark and without.
        UTF32Encoding u32LeNone = new UTF32Encoding();
        UTF32Encoding u32BeNone = new UTF32Encoding(true,
 false);
        UTF32Encoding u32LeBom = new UTF32Encoding(false,
 true);
        UTF32Encoding u32BeBom = new UTF32Encoding(true,
 true);

        // Display the preamble for each instance.
        PrintHexBytes(u32LeNone.GetPreamble());
        PrintHexBytes(u32BeNone.GetPreamble());
        PrintHexBytes(u32LeBom.GetPreamble());
        PrintHexBytes(u32BeBom.GetPreamble());
    } //main
   
    public static void PrintHexBytes(ubyte
 bytes[])
    {
        if(bytes == null || bytes.length ==
 0) {
            Console.WriteLine("<none>");
        }
        else {
            for(int i = 0; i < bytes.length;
 i++) {
                Console.Write("{0:X2} ", 
                    ((System.Byte)bytes[i]).ToString("X2"));
            }
            Console.WriteLine();
        }
    } //PrintHexBytes
} //SamplesUTF32Encoding

/* 
This code produces the following output.

FF FE 00 00
<none>
FF FE 00 00
00 00 FE FF

*/

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


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

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

辞書ショートカット

すべての辞書の索引

UTF32Encoding.GetPreamble メソッドのお隣キーワード
検索ランキング

   

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



UTF32Encoding.GetPreamble メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS