public static int[] ParseCombiningCharacters(string str)
{
if (str == null)
{
throw new ArgumentNullException("str");
}
int length = str.Length;
int[] array = new int[length];
if (length == 0)
{
return(array);
}
int num = 0;
int i = 0;
int num2;
UnicodeCategory unicodeCategory = CharUnicodeInfo.InternalGetUnicodeCategory(str, 0, out num2);
while (i < length)
{
array[num++] = i;
i += StringInfo.GetCurrentTextElementLen(str, i, length, ref unicodeCategory, ref num2);
}
if (num < length)
{
int[] array2 = new int[num];
Array.Copy(array, array2, num);
return(array2);
}
return(array);
}