diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-11-19 13:27:27 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-11-19 13:27:27 -0500 |
| commit | ccada385c4fdc2dc320b0ab468c7413ff27bcc7d (patch) | |
| tree | a9a70ea9b014212952c8d61a0bb5a0ff58a45f88 /docs/text.md | |
| parent | e97c3850b817f6bda6f7ea3fff5c345c5f48bcd8 (diff) | |
Add Text.at(i) for getting a single cluster
Diffstat (limited to 'docs/text.md')
| -rw-r--r-- | docs/text.md | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/docs/text.md b/docs/text.md index 6278da2b..d0179bc4 100644 --- a/docs/text.md +++ b/docs/text.md @@ -426,6 +426,35 @@ A C-style string (`CString`) representing the text. --- +## `at` + +**Description:** +Get the graphical cluster at a given index. This is similar to `str[i]` with +ASCII text, but has more correct behavior for unicode text. + +**Signature:** +```tomo +func at(text: Text, index: Int -> Text) +``` + +**Parameters:** + +- `text`: The text from which to get a cluster. +- `index`: The index of the graphical cluster (1-indexed). + +**Returns:** +A `Text` with the single graphical cluster at the given index. Note: negative +indices are counted from the back of the text, so `-1` means the last cluster, +`-2` means the second-to-last, and so on. + +**Example:** +```tomo +>> "Amélie":at(3) += "é" +``` + +--- + ## `utf8_bytes` **Description:** |
