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

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

TextElementEnumerator クラス

文字列テキスト要素列挙します

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

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Class TextElementEnumerator
    Implements IEnumerator
Dim instance As TextElementEnumerator
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public class TextElementEnumerator : IEnumerator
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public ref class TextElementEnumerator : IEnumerator
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public class TextElementEnumerator implements
 IEnumerator
SerializableAttribute 
ComVisibleAttribute(true) 
public class TextElementEnumerator implements
 IEnumerator
解説解説

.NET Framework は、単一文字として表示されるテキスト単位、つまり書記素としてテキスト要素定義しますテキスト要素は、基本文字サロゲート ペア、または組み合わせた文字シーケンス場合ありますUnicode Standard は、サロゲート ペア2 つコード単位から成る単一抽象文字を表すコード化文字表現として定義しますペア最初単位上位サロゲート2 番目の単位下位サロゲートとなりますUnicode Standard は、組み合わせ文字シーケンス1 つ基本文字1 つ上の組み合わせ文字組み合わせとして定義しますサロゲート ペアは、基本文字または組み合わせた文字を表すことができますサロゲート ペアおよび組み合わせ文字シーケンス詳細については、http://www.unicode.org の「The Unicode Standard」を参照してください

テキスト要素の列挙子は、文字列内のデータ読み取ることだけを目的として使用されます。列挙子は、基になる文字列変更するためには使用できません。

列挙子には、文字列への排他アクセス権はありません。

列挙子は、作成されるときに文字列の現在の状態スナップショット取得しますテキスト要素追加変更削除などの変更文字列に対して実行されると、スナップショット同期されなくなり列挙子は InvalidOperationException をスローます。同じ文字列から同時に作成され2 つ列挙子が、その文字列異なスナップショットを持つこともできます

文字列最初テキスト要素の前、または文字列の最後テキスト要素の後に位置している列挙子は無効な状態です。列挙子が無効な状態の場合Current呼び出すと、必ず例外スローさます。

初期状態では、列挙は文字列の最初テキスト要素前に位置してます。Reset実行した場合も、列挙子はこの位置に戻されます。たがって列挙子を作成した後や Reset呼び出した後に、文字列最初テキスト要素列挙子を進めるためには、Current の値を読み取る前に MoveNext を呼び出す必要があります

Current は、MoveNext または Reset呼び出されるまでは同じオブジェクト返します

文字列末尾を過ぎると列挙子が再び無効な状態になるため、MoveNext呼び出すと false返されます。MoveNext への最後呼び出しfalse返され場合Current呼び出すと、例外スローさます。

使用例使用例

TextElementEnumerator によって返される値を次のコード例示します

Imports System
Imports System.Globalization
Imports Microsoft.VisualBasic

Public Class SamplesTextElementEnumerator

   Public Shared Sub Main()

      ' Creates and initializes a String containing the following:
      '   - a surrogate pair (high surrogate U+D800 and low surrogate
 U+DC00)
      '   - a combining character sequence (the Latin small letter "a"
 followed by the combining grave accent)
      '   - a base character (the ligature "")
      Dim myString As String
 = ChrW(&HD800) & ChrW(&HDC00) & ChrW(&H0061) & ChrW(&H0300)
 & ChrW(&H00C6)

      ' Creates and initializes a TextElementEnumerator for myString.
      Dim myTEE As TextElementEnumerator =
 StringInfo.GetTextElementEnumerator( myString )

      ' Displays the values returned by ElementIndex, Current and GetTextElement.
      ' Current and GetTextElement return a string containing the entire
 text element. 
      Console.WriteLine("Index" + ControlChars.Tab
 + "Current" + ControlChars.Tab + "GetTextElement")
      myTEE.Reset()
      While myTEE.MoveNext()
         Console.WriteLine("[{0}]:" + ControlChars.Tab
 + "{1}" + ControlChars.Tab + "{2}",
 myTEE.ElementIndex, myTEE.Current, myTEE.GetTextElement())
      End While

   End Sub 'Main 

End Class 'SamplesTextElementEnumerator

'This code produces the following output.  The question marks take the
 place of high and low surrogates.
'
'Index   Current GetTextElement
'[0]:    ??      ??
'[2]:    a`      a`
'[4]:           

using System;
using System.Globalization;


public class SamplesTextElementEnumerator 
 {

   public static void Main()
  {

      // Creates and initializes a String containing the following:
      //   - a surrogate pair (high surrogate U+D800 and low surrogate
 U+DC00)
      //   - a combining character sequence (the Latin small letter
 "a" followed by the combining grave accent)
      //   - a base character (the ligature "")
      String myString = "\uD800\uDC00\u0061\u0300\u00C6";

      // Creates and initializes a TextElementEnumerator for myString.
      TextElementEnumerator myTEE = StringInfo.GetTextElementEnumerator( myString
 );

      // Displays the values returned by ElementIndex, Current and GetTextElement.
      // Current and GetTextElement return a string containing the entire
 text element. 
      Console.WriteLine( "Index\tCurrent\tGetTextElement" );
      myTEE.Reset();
      while (myTEE.MoveNext())  {
         Console.WriteLine( "[{0}]:\t{1}\t{2}", myTEE.ElementIndex, myTEE.Current,
 myTEE.GetTextElement() );
      }

   }

}

/*
This code produces the following output.  The question marks take the place of high
 and low surrogates.

Index   Current GetTextElement
[0]:    ??      ??
[2]:    a`      a`
[4]:           

*/
using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Creates and initializes a String containing the following:
   //   - a surrogate pair (high surrogate U+D800 and low surrogate
 U+DC00)
   //   - a combining character sequence (the Latin small letter S"a"
 followed by the combining grave accent)
   //   - a base character (the ligature S"")
   String^ myString = L"\xD800\xDC00"
   L"a\u0300\u00C6";
   
   // Creates and initializes a TextElementEnumerator for myString.
   TextElementEnumerator^ myTEE = StringInfo::GetTextElementEnumerator( myString
 );
   
   // Displays the values returned by ElementIndex, Current and GetTextElement.
   // Current and GetTextElement return a String* containing the entire
 text element. 
   Console::WriteLine( "Index\tCurrent\tGetTextElement" );
   myTEE->Reset();
   while ( myTEE->MoveNext() )
      Console::WriteLine( "[{0}]:\t {1}\t {2}", myTEE->ElementIndex,
 myTEE->Current, myTEE->GetTextElement() );
}

/*
This code produces the following output.  The question marks take the place of high
 and low surrogates.

Index   Current GetTextElement
[0]:    ??      ??
[2]:    a`      a`
[4]:           

*/
import System.*;
import System.Globalization.*;

public class SamplesTextElementEnumerator
{
    public static void main(String[]
 args)
    {
        // Creates and initializes a String containing the following:
        //   - a surrogate pair (high surrogate U+D800 and low surrogate
 U+DC00)
        //   - a combining character sequence (the Latin small letter
 "a" 
        //     followed by the combining grave accent)
        //   - a base character (the ligature "")
        String myString = "\uD800\uDC00\u0061\u0300\u00C6";

        // Creates and initializes a TextElementEnumerator for myString.
        TextElementEnumerator myTEE = 
            StringInfo.GetTextElementEnumerator(myString);

        // Displays the values returned by ElementIndex, Current and
 
        // GetTextElement.
        // Current and GetTextElement return a string containing the
 entire 
        // text element. 
        Console.WriteLine("Index\tCurrent\tGetTextElement");
        myTEE.Reset();
        while(myTEE.MoveNext()) {
            Console.WriteLine("[{0}]:\t{1}\t{2}", 
                System.Convert.ToString(myTEE.get_ElementIndex()),
                System.Convert.ToString(myTEE.get_Current()),
                myTEE.GetTextElement());
        }
    } //main
} //SamplesTextElementEnumerator

/*
This code produces the following output.  
The question marks take the place of high and low surrogates.

Index   Current GetTextElement
[0]:    ??      ??
[2]:    a`      a`
[4]:                      

*/
継承階層継承階層
System.Object
  System.Globalization.TextElementEnumerator
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TextElementEnumerator メンバ
System.Globalization 名前空間
System.Collections.IEnumerator



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

辞書ショートカット

すべての辞書の索引

「TextElementEnumerator クラス」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS