1 library(unicode): Unicode string handling
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog Unicode library
        • library(unicode): 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
Availability::- use_module(library(unicode)).(can be autoloaded)
Source[det]atom_graphemes(?Atom, ?Graphemes)
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.