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

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

UTF8Encoding.GetPreamble メソッド

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

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

解説解説
使用例使用例

次の例は、GetPreamble メソッド使用してUTF-8 形式エンコードされた Unicode バイト順マーク返す方法示してます。UTF8Encoding既定コンストラクタプリアンブル提供しません。

Imports System
Imports System.Text

Class UTF8EncodingExample
    
    Public Shared Sub Main()
        ' The default constructor does not provide a preamble.
        Dim UTF8NoPreamble As New
 UTF8Encoding()
        Dim UTF8WithPreamble As New
 UTF8Encoding(True)
        
        Dim preamble() As Byte
        
        preamble = UTF8NoPreamble.GetPreamble()
        Console.WriteLine("UTF8NoPreamble")
        Console.WriteLine(" preamble length: {0}",
 preamble.Length)
        Console.Write(" preamble: ")
        ShowArray(preamble)
        
        preamble = UTF8WithPreamble.GetPreamble()
        Console.WriteLine("UTF8WithPreamble")
        Console.WriteLine(" preamble length: {0}",
 preamble.Length)
        Console.Write(" preamble: ")
        ShowArray(preamble)
    End Sub 'Main
    
    
    Public Shared Sub ShowArray(theArray
 As Array)
        Dim o As Object
        For Each o In  theArray
            Console.Write("[{0}]", o)
        Next o
        Console.WriteLine()
    End Sub 'ShowArray
End Class 'UTF8EncodingExample
using System;
using System.Text;

class UTF8EncodingExample {
    public static void Main()
 {
        // The default constructor does not provide a preamble.
        UTF8Encoding UTF8NoPreamble = new UTF8Encoding();
        UTF8Encoding UTF8WithPreamble = new UTF8Encoding(true);

        Byte[] preamble;

        preamble = UTF8NoPreamble.GetPreamble();
        Console.WriteLine("UTF8NoPreamble");
        Console.WriteLine(" preamble length: {0}", preamble.Length);
        Console.Write(" preamble: ");
        ShowArray(preamble);

        preamble = UTF8WithPreamble.GetPreamble();
        Console.WriteLine("UTF8WithPreamble");
        Console.WriteLine(" preamble length: {0}", preamble.Length);
        Console.Write(" preamble: ");
        ShowArray(preamble);
    }

    public static void ShowArray(Array
 theArray) {
        foreach (Object o in theArray) {
            Console.Write("[{0}]", o);
        }
        Console.WriteLine();
    }
}
using namespace System;
using namespace System::Text;
using namespace System::Collections;
void ShowArray( Array^ theArray )
{
   IEnumerator^ myEnum = theArray->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      Object^ o = safe_cast<Object^>(myEnum->Current);
      Console::Write( "[{0}]", o );
   }

   Console::WriteLine();
}

int main()
{
   
   // The default constructor does not provide a preamble.
   UTF8Encoding^ UTF8NoPreamble = gcnew UTF8Encoding;
   UTF8Encoding^ UTF8WithPreamble = gcnew UTF8Encoding( true );
   array<Byte>^preamble;
   preamble = UTF8NoPreamble->GetPreamble();
   Console::WriteLine( "UTF8NoPreamble" );
   Console::WriteLine( " preamble length: {0}", preamble->Length );
   Console::Write( " preamble: " );
   ShowArray( preamble );
   preamble = UTF8WithPreamble->GetPreamble();
   Console::WriteLine( "UTF8WithPreamble" );
   Console::WriteLine( " preamble length: {0}", preamble->Length );
   Console::Write( " preamble: " );
   ShowArray( preamble );
}

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

class UTF8EncodingExample
{
    public static void main(String[]
 args)
    {
        // The default constructor does not provide a preamble.
        UTF8Encoding utf8NoPreamble = new UTF8Encoding();
        UTF8Encoding utf8WithPreamble = new UTF8Encoding(true);
        ubyte preamble[];

        preamble = utf8NoPreamble.GetPreamble();
        Console.WriteLine("UTF8NoPreamble");
        Console.WriteLine(" preamble length: {0}",
            String.valueOf(preamble.length));
        Console.Write(" preamble: ");
        ShowArray(preamble);
        preamble = utf8WithPreamble.GetPreamble();
        Console.WriteLine("UTF8WithPreamble");
        Console.WriteLine(" preamble length: {0}",
            String.valueOf(preamble.length));
        Console.Write(" preamble: ");
        ShowArray(preamble);
    } //main

    public static void ShowArray(Array
 theArray)
    {
        Object o = null;
        for (int iCtr = 0; iCtr < theArray.get_Count();
 iCtr++) {
            o = theArray.get_Item(iCtr);
            Console.Write("[{0}]", o);
        }
        Console.WriteLine();
    } //ShowArray
} //UTF8EncodingExample
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2024 GRAS Group, Inc.RSS