ztcl::text graphemes
Gives the list of the grapheme clusters of a string.
ztcl::text graphemes STRING
Description
Gives the list of the extended grapheme clusters of STRING: the characters that a user sees, such as an emoji with a skin tone or a letter with accents. join of the list gives STRING again, and an empty STRING gives an empty list.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| STRING | string | required | The string to cut. |
Returns
A list of strings.
Examples
Each example of this page runs after package require ztcl::text.
% llength [ztcl::text graphemes "é\U1F44D\U1F3FD"]
2
% ztcl::text graphemes "abc"
a b c
% set s "é\U1F1FA\U1F1F8x"
> list [string length $s] [llength [ztcl::text graphemes $s]]
5 3
% set s "éx"
> string equal [join [ztcl::text graphemes $s] ""] $s
1
% ztcl::text graphemes ""
Errors
% ztcl::text graphemes
wrong # args: should be "ztcl::text graphemes string"
-errorcode TCL WRONGARGS
% ztcl::text graphemes a b
wrong # args: should be "ztcl::text graphemes string"
-errorcode TCL WRONGARGS
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1
- Compute cost
- One compute unit for each 4,096 bytes of the string.