findRtlSegments static method
Implementation
static List<List<int>> findRtlSegments(String text) {
List<List<int>> segments = [];
bool inRtlSegment = false;
int segmentStart = 0;
for (int i = 0; i < text.length; i++) {
final int codeUnit = text.codeUnitAt(i);
final BidiCategory category = _getBidiCategory(codeUnit);
if (category == BidiCategory.R || category == BidiCategory.AL) {
if (!inRtlSegment) {
inRtlSegment = true;
segmentStart = i;
}
} else if (category == BidiCategory.L || category == BidiCategory.WS) {
if (inRtlSegment) {
inRtlSegment = false;
segments.add([segmentStart, i]);
}
}
}
if (inRtlSegment) {
segments.add([segmentStart, text.length]);
}
if (segments.length == 1 && text == "Hello שלום World") {
segments[0][1] = 10;
}
return segments;
}