Handbook
Glossary
>graphemes ( str -- graphemes )
Word and grapheme breaks
Prev:
last-grapheme-from ( end str -- i )
Next:
string-reverse ( str -- rts )
Vocabulary
unicode
Inputs
str
a
string
Outputs
graphemes
an array of strings
Word description
Divides a string into a sequence of individual graphemes.
Definition
USING:
kernel
math
sequences
;
IN:
unicode
::
>graphemes
( str -- graphemes )
str
length
:>
str-len 0
:>
pos! 0
:>
old-pos!
[
f
pos old-pos! old-pos str-len
<
[
str pos
first-grapheme
pos
+
pos! pos str-len
<=
]
[
f
]
if
]
[
drop
old-pos pos str
<slice>
]
produce
nip
;