public void Reset() { index = startIndex; if (index < strLen) { // If we have more than 1 character, get the category of the current char. uc = CharUnicodeInfo.InternalGetUnicodeCategory(str, index, out charLen); } } }
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(); } } }