/usr/lib/swipl/library/ext/utf8proc/unicode.pl
All Application Manual Name SummaryHelp

  • ext
    • utf8proc
      • unicode.pl -- Unicode string handling
        • unicode_map/3
        • unicode_nfd/2
        • unicode_nfc/2
        • unicode_nfkd/2
        • unicode_nfkc/2
        • unicode_nfkc_casefold/2
        • unicode_casefold/2
        • unicode_property/2
        • atom_graphemes/2
        • string_graphemes/2
        • unicode_version/1
        • unicode_codepoint_valid/1
      • unicode_security.pl -- Unicode security helpers (UTS #39, UAX #24)
 atom_graphemes(?Atom, ?Graphemes) is det
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.