Relate Atom to a list of its grapheme clusters. Grapheme clusters
are "user-perceived characters" as defined by UAX#29 --- e.g. the
precomposed U+00E9 (LATIN SMALL LETTER E WITH ACUTE) and the
decomposed sequence e + U+0301 are both one grapheme, an emoji
ZWJ sequence such as MAN + ZWJ + WOMAN + ZWJ + GIRL is one
grapheme, and a regional-indicator pair (e.g. U+1F1F3 U+1F1F1,
rendered as the Dutch flag) is one grapheme.
In the forward mode (+Atom, ?Graphemes), Atom is decomposed into
a list of atoms, each covering one cluster. In the reverse mode
(?Atom, +Graphemes), the elements of Graphemes are concatenated
into Atom. Both arguments instantiated means both modes run and
the result must agree.
?- atom_codes(A, [0'c, 0'a, 0'f, 0'e, 0x0301]),
atom_graphemes(A, Gs).
Gs = [c, a, f, G],
atom_codes(G, [0'e, 0x0301]).
?- atom_graphemes(A, [a, b, c]).
A = abc.
- See also
- - string_graphemes/2 for the string analogue.