UScriptRun is used to find runs of characters in
the same script, as defined in the
UScript class.
It implements a simple iterator over an array of characters.
The iterator will assign
COMMON and
INHERITED
characters to the same script as the preceding characters. If the
COMMON and INHERITED characters are first, they will be assigned to
the same script as the following characters.
The iterator will try to match paired punctuation. If it sees an
opening punctuation character, it will remember the script that
was assigned to that character, and assign the same script to the
matching closing punctuation.
No attempt is made to combine related scripts into a single run. In
particular, Hiragana, Katakana, and Han characters will appear in separate
runs.
Here is an example of how to iterate over script runs:
void printScriptRuns(char[] text)
{
UScriptRun scriptRun = new UScriptRun(text);
while (scriptRun.next()) {
int start = scriptRun.getScriptStart();
int limit = scriptRun.getScriptLimit();
int script = scriptRun.getScriptCode();
System.out.println("Script \"" + UScript.getName(script) + "\" from " +
start + " to " + limit + ".");
}
}