System.Globalization.TextElementEnumerator.MoveNext C# (CSharp) Method

MoveNext() public method

public MoveNext ( ) : bool
return bool
        public bool MoveNext()
        {
            if (index >= strLen)
            {
                // Make the index to be greater than strLen so that we can throw exception if GetTextElement() is called.
                index = strLen + 1;
                return (false);
            }
            currTextElementLen = StringInfo.GetCurrentTextElementLen(str, index, strLen, ref uc, ref charLen);
            index += currTextElementLen;
            return (true);
        }

Usage Example

Esempio n. 1
0
    public void OnValueChange()
    {
        if (field != null)
        {
            string inStr = field.text;

            if (inStr.Length != 0)
            {
                System.Text.StringBuilder retStr = new System.Text.StringBuilder();
                System.Globalization.TextElementEnumerator tee =
                    System.Globalization.StringInfo.GetTextElementEnumerator(inStr);
                tee.Reset();

                while (tee.MoveNext())
                {
                    // 1文字取得
                    var te = tee.GetTextElement();
                    // 1文字が2つ以上のcharからなる場合は、サロゲートペアと判断
                    if (1 < te.Length)
                    {
                        // 文字列から除去
                    }
                    else
                    {
                        retStr = retStr.Append(te);
                    }
                }
                // InputFieldに返す
                field.text = retStr.ToString();
            }
        }
    }
All Usage Examples Of System.Globalization.TextElementEnumerator::MoveNext