diff options
Diffstat (limited to 'src/stdlib/text.c')
| -rw-r--r-- | src/stdlib/text.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/stdlib/text.c b/src/stdlib/text.c index b6b7e0bb..cda7dd31 100644 --- a/src/stdlib/text.c +++ b/src/stdlib/text.c @@ -726,7 +726,10 @@ Text_t Text$reversed(Text_t text) { } public -PUREFUNC Text_t Text$cluster(Text_t text, Int_t index) { return Text$slice(text, index, index); } +PUREFUNC OptionalText_t Text$cluster(Text_t text, Int_t index) { + Text_t slice = Text$slice(text, index, index); + return slice.length <= 0 ? NONE_TEXT : slice; +} static Text_t Text$from_components(List_t graphemes, Table_t unique_clusters) { size_t blob_size = (sizeof(int32_t[unique_clusters.entries.length]) + sizeof(uint8_t[graphemes.length])); |
