private BreakIteratorWrapper GetBreakIterator(int scriptCode) { if (wordBreakers[scriptCode] == null) { wordBreakers[scriptCode] = BreakIteratorWrapper.Wrap(config.GetBreakIterator(scriptCode)); } return(wordBreakers[scriptCode]); }
/// <summary> /// Retrieve the next break position. If the RBBI range is exhausted within the /// script boundary, examine the next script boundary. /// </summary> /// <returns>The next break position or <see cref="BreakIterator.Done"/>.</returns> public int Next() { int next = rbbi.Next(); while (next == BreakIterator.Done && scriptIterator.Next()) { rbbi = GetBreakIterator(scriptIterator.ScriptCode); rbbi.SetText(text, scriptIterator.ScriptStart, scriptIterator.ScriptLimit - scriptIterator.ScriptStart); next = rbbi.Next(); } return((next == BreakIterator.Done) ? BreakIterator.Done : next + scriptIterator.ScriptStart); }
/// <summary> /// Set a new region of text to be examined by this iterator. /// </summary> /// <param name="text">Buffer of text.</param> /// <param name="start">Offset into buffer.</param> /// <param name="length">Maximum length to examine.</param> public void SetText(char[] text, int start, int length) { this.text = text; scriptIterator.SetText(text, start, length); if (scriptIterator.Next()) { rbbi = GetBreakIterator(scriptIterator.ScriptCode); rbbi.SetText(text, scriptIterator.ScriptStart, scriptIterator.ScriptLimit - scriptIterator.ScriptStart); } else { rbbi = GetBreakIterator(UScript.Common); rbbi.SetText(text, 0, 0); } }