StringInfo.ParseCombiningCharacters メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim str As String Dim returnValue As Integer() returnValue = StringInfo.ParseCombiningCharacters(str)
戻り値
指定した文字列の各基本文字、上位サロゲート、または制御文字の、0 から始まるインデックス番号を格納している整数の配列。


Unicode Standard は、サロゲート ペアを 2 つのコード単位から成る単一の抽象文字を表すコード化文字表現として定義します。ペアの最初の単位が上位サロゲート、2 番目の単位が下位サロゲートとなります。上位サロゲートは U+D800 ~ U+DBFF の範囲の Unicode コード ポイントであり、下位サロゲートは U+DC00 ~ U+DFFF の範囲の Unicode コード ポイントです。
制御文字とは、Unicode 値が U+007F であるか、U+0000 ~ U+001F または U+0080 ~ U+009F の範囲の文字のことを指します。
.NET Framework は、単一の文字として表示されるテキストの単位、つまり書記素としてテキスト要素を定義します。テキスト要素は、基本文字、サロゲート ペア、または組み合わせた文字シーケンスの場合があります。Unicode Standard は、組み合わせ文字シーケンスを 1 つの基本文字と 1 つ以上の組み合わせ文字の組み合わせとして定義します。サロゲート ペアは、基本文字または組み合わせた文字を表すことができます。サロゲート ペアおよび組み合わせ文字シーケンスの詳細については、http://www.unicode.org の「The Unicode Standard」を参照してください。
組み文字シーケンスが無効な場合は、そのシーケンスのすべての組み文字も返されます。
結果として返される配列の各インデックスは、テキスト要素の先頭、つまり、基本文字または上位サロゲートのインデックスです。
各要素の長さは、連続するインデックス間の差として簡単に計算できます。配列の長さは、常に文字列の長さ以下になります。たとえば、文字列 "\u4f00\u302a\ud800\udc00\u4f01" では、このメソッドはインデックス 0、2、および 4 を返します。
等価のメンバ
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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


StringInfo クラス
StringInfo メンバ
System.Globalization 名前空間
SubstringByTextElements
LengthInTextElements
Weblioに収録されているすべての辞書からStringInfo.ParseCombiningCharacters メソッドを検索する場合は、下記のリンクをクリックしてください。

- StringInfo.ParseCombiningCharacters メソッドのページへのリンク