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

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

StringInfo.ParseCombiningCharacters メソッド

指定した文字列の各基本文字上位サロゲート、または制御文字インデックス返します

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

Public Shared Function ParseCombiningCharacters
 ( _
    str As String _
) As Integer()
Dim str As String
Dim returnValue As Integer()

returnValue = StringInfo.ParseCombiningCharacters(str)
public static int[] ParseCombiningCharacters
 (
    string str
)
public:
static array<int>^ ParseCombiningCharacters
 (
    String^ str
)
public static int[] ParseCombiningCharacters
 (
    String str
)
public static function ParseCombiningCharacters
 (
    str : String
) : int[]

パラメータ

str

検索対象文字列

戻り値
指定した文字列の各基本文字上位サロゲート、または制御文字の、0 から始まるインデックス番号格納している整数配列

例外例外
例外種類条件

ArgumentNullException

strnull 参照 (Visual Basic では Nothing) です。

解説解説

Unicode Standard は、サロゲート ペア2 つコード単位から成る単一抽象文字を表すコード化文字表現として定義しますペア最初単位上位サロゲート2 番目の単位下位サロゲートとなります上位サロゲートU+D800 ~ U+DBFF の範囲Unicode コード ポイントであり、下位サロゲートU+DC00 ~ U+DFFF の範囲Unicode コード ポイントです。

制御文字とは、Unicode 値が U+007F であるか、U+0000U+001F または U+0080U+009F の範囲文字のことを指します

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

組み文字シーケンス無効な場合は、そのシーケンスすべての組み文字返されます。

結果として返される配列の各インデックスは、テキスト要素先頭、つまり、基本文字または上位サロゲートインデックスです。

各要素長さは、連続するインデックス間の差として簡単に計算できます配列長さは、常に文字列の長さ以下になります。たとえば、文字列 "\u4f00\u302a\ud800\udc00\u4f01" では、このメソッドインデックス 0、2、および 4 を返します

等価メンバ

.NET Framework Version 2.0 以降では、SubstringByTextElements メソッドおよび LengthInTextElements プロパティにより、ParseCombiningCharacters メソッド提供する機能実装簡単に使用できます

使用例使用例

ParseCombiningCharacters メソッド呼び出しについては、次のコード例参照してください。このコード例は、StringInfo クラストピック取り上げているコード例一部分です。

using System;
using System.Text;
using System.Globalization;

public sealed class App {
   static void Main() {
      // The string below contains combining characters.
      String s = "a\u0304\u0308bc\u0327";

      // Show each 'character' in the string.
      EnumTextElements(s);

      // Show the index in the string where each 'character' starts.
      EnumTextElementIndexes(s);
   }

   // Show how to enumerate each real character (honoring surrogates)
 in a string.
   static void EnumTextElements(String s) {
      // This StringBuilder holds the output results.
      StringBuilder sb = new StringBuilder();

      // Use the enumerator returned from GetTextElementEnumerator 
      // method to examine each real character.
      TextElementEnumerator charEnum = StringInfo.GetTextElementEnumerator(s);
      while (charEnum.MoveNext()) {
         sb.AppendFormat(
           "Character at index {0} is '{1}'{2}",
           charEnum.ElementIndex, charEnum.GetTextElement(),
           Environment.NewLine);
      }

      // Show the results.
      Console.WriteLine("Result of GetTextElementEnumerator:");
      Console.WriteLine(sb);
   }

   // Show how to discover the index of each real character (honoring
 surrogates) in a string.
   static void EnumTextElementIndexes(String
 s) {
      // This StringBuilder holds the output results.
      StringBuilder sb = new StringBuilder();

      // Use the ParseCombiningCharacters method to 
      // get the index of each real character in the string.
      Int32[] textElemIndex = StringInfo.ParseCombiningCharacters(s);

      // Iterate through each real character showing the character and
 the index where it was found.
      for (Int32 i = 0; i < textElemIndex.Length; i++) {
         sb.AppendFormat(
            "Character {0} starts at index {1}{2}",
            i, textElemIndex[i], Environment.NewLine);
      }

      // Show the results.
      Console.WriteLine("Result of ParseCombiningCharacters:");
      Console.WriteLine(sb);
   }
}

// This code produces the following output.
//
// Result of GetTextElementEnumerator:
// Character at index 0 is 'a-"'
// Character at index 3 is 'b'
// Character at index 4 is 'c,'
// 
// Result of ParseCombiningCharacters:
// Character 0 starts at index 0
// Character 1 starts at index 3
// Character 2 starts at index 4
using namespace System;
using namespace System::Text;
using namespace System::Globalization;


// Show how to enumerate each real character (honoring surrogates)
// in a string.

void EnumTextElements(String^ combiningChars)
{
    // This StringBuilder holds the output results.
    StringBuilder^ sb = gcnew StringBuilder();

    // Use the enumerator returned from GetTextElementEnumerator
    // method to examine each real character.
    TextElementEnumerator^ charEnum =
        StringInfo::GetTextElementEnumerator(combiningChars);
    while (charEnum->MoveNext())
    {
        sb->AppendFormat("Character at index {0} is '{1}'{2}", 
            charEnum->ElementIndex, charEnum->GetTextElement(), 
            Environment::NewLine);
    }

    // Show the results.
    Console::WriteLine("Result of GetTextElementEnumerator:");
    Console::WriteLine(sb);
}


// Show how to discover the index of each real character
// (honoring surrogates) in a string.

void EnumTextElementIndexes(String^ combiningChars)
{
    // This StringBuilder holds the output results.
    StringBuilder^ sb = gcnew StringBuilder();

    // Use the ParseCombiningCharacters method to
    // get the index of each real character in the string.
    array <int>^ textElemIndex =
        StringInfo::ParseCombiningCharacters(combiningChars);

    // Iterate through each real character showing the character
    // and the index where it was found.
    for (int i = 0; i < textElemIndex->Length;
 i++)
    {
        sb->AppendFormat("Character {0} starts at index {1}{2}",
            i, textElemIndex[i], Environment::NewLine);
    }

    // Show the results.
    Console::WriteLine("Result of ParseCombiningCharacters:");
    Console::WriteLine(sb);
}

int main()
{

    // The string below contains combining characters.
    String^ combiningChars = L"a\u0304\u0308bc\u0327";

    // Show each 'character' in the string.
    EnumTextElements(combiningChars);

    // Show the index in the string where each 'character' starts.
    EnumTextElementIndexes(combiningChars);

};

// This code produces the following output.
//
// Result of GetTextElementEnumerator:
// Character at index 0 is 'a-"'
// Character at index 3 is 'b'
// Character at index 4 is 'c,'
//
// Result of ParseCombiningCharacters:
// Character 0 starts at index 0
// Character 1 starts at index 3
// Character 2 starts at index 4
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
StringInfo クラス
StringInfo メンバ
System.Globalization 名前空間
SubstringByTextElements
LengthInTextElements


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

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

辞書ショートカット

すべての辞書の索引

「StringInfo.ParseCombiningCharacters メソッド」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS