public static class WordBreakerWhere one word ends and the next begins.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
What double-click selection and ctrl-arrow movement are measured in. Words are not "runs between spaces": can't is one word and 1,000.50 is one number, while -- is neither, and getting it wrong is the kind of thing nobody files a bug about and everybody notices.
UAX#29's word rules, which are harder than the cluster rules in one specific way: several of them look past the pair in hand. WB6 holds letter × MidLetter letter together, so deciding whether to break before the apostrophe in can't requires knowing there is a t after it. So this works over a decoded array with lookahead rather than a streaming pair, and the ignore rule — WB4, which makes format characters and extenders invisible to every other rule — is applied by skipping rather than by classifying.
Judged by the Consortium's 1 944 cases, not by a reading of the specification.
Methods (3)
public static void Collect(ReadOnlySpan<char> text, List<int> boundaries)Collects every word boundary in a string.
public static List<int> Boundaries(string text)Every word boundary in a string.
public static (int Start, int End) WordAt(ReadOnlySpan<char> text, int index)The word containing a position.
Used by (3)
- SegmentationTestsVixen.Ui.Text.Tests
- TextFieldVixen.Ui.Controls
- UnicodeConformanceVixen.Ui.Text.Tests