TextStudioTextUnitBoundary
public static class TextStudioTextUnitBoundaryAllocation-free Unicode text-unit traversal using UTF-16 offsets. Inline objects remain atomic.
Methods
Section titled “Methods”
Count(string)
Section titled “Count(string)”public static int Count(string text)Counts Unicode text units in a string, returning zero for null or empty text.
Parameters
| Name | Type |
|---|---|
text | System.String |
Returns
System.Int32
GetPrefixLength(string, int)
Section titled “GetPrefixLength(string, int)”public static int GetPrefixLength(string text, int maximumUnits)Returns the UTF-16 length of a prefix containing at most the requested number of complete text units.
Parameters
| Name | Type |
|---|---|
text | System.String |
maximumUnits | System.Int32 |
Returns
System.Int32
FloorBoundary(string, int)
Section titled “FloorBoundary(string, int)”public static int FloorBoundary(string text, int index)Returns the nearest text-unit boundary at or before the supplied UTF-16 offset, clamped to the string.
Parameters
| Name | Type |
|---|---|
text | System.String |
index | System.Int32 |
Returns
System.Int32
CeilingBoundary(string, int)
Section titled “CeilingBoundary(string, int)”public static int CeilingBoundary(string text, int index)Returns the nearest text-unit boundary at or after the supplied UTF-16 offset, clamped to the string.
Parameters
| Name | Type |
|---|---|
text | System.String |
index | System.Int32 |
Returns
System.Int32
Move(string, int, int)
Section titled “Move(string, int, int)”public static int Move(string text, int index, int offset)Moves by a signed number of complete text units from the floored UTF-16 offset, stopping at string boundaries.
Parameters
| Name | Type |
|---|---|
text | System.String |
index | System.Int32 |
offset | System.Int32 |
Returns
System.Int32
CountBefore(string, int)
Section titled “CountBefore(string, int)”public static int CountBefore(string text, int index)Counts complete text units ending at or before the supplied UTF-16 offset.
Parameters
| Name | Type |
|---|---|
text | System.String |
index | System.Int32 |
Returns
System.Int32
GetPreviousBoundary(string, int)
Section titled “GetPreviousBoundary(string, int)”public static int GetPreviousBoundary(string text, int index)Returns the preceding text-unit boundary for the supplied UTF-16 offset, or zero at the start of the string.
Parameters
| Name | Type |
|---|---|
text | System.String |
index | System.Int32 |
Returns
System.Int32
GetUnitEnd(string, int)
Section titled “GetUnitEnd(string, int)”public static int GetUnitEnd(string text, int unitStart)Returns the UTF-16 end offset of the text unit beginning at the supplied offset, keeping inline objects atomic.
Parameters
| Name | Type |
|---|---|
text | System.String |
unitStart | System.Int32 |
Returns
System.Int32