Function: string-glyph-split
string-glyph-split is an autoloaded and byte-compiled function defined
in subr-x.el.gz.
Signature
(string-glyph-split STRING)
Documentation
Split STRING into a list of strings representing separate glyphs.
This takes into account combining characters and grapheme clusters: if compositions are enabled, each sequence of characters composed on display into a single grapheme cluster is treated as a single indivisible unit.
Other relevant functions are documented in the string group.
Probably introduced at or before Emacs version 29.1.
Shortdoc
;; string
(string-glyph-split "Hello, πΌπ»π§πΌβπ€βπ§π»")
=> ("H" "e" "l" "l" "o" "," " " "πΌ" "π»" "π§" "πΌ" "β" "π€" "β" "π§" "π»")
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/subr-x.el.gz
;;;###autoload
(defun string-glyph-split (string)
"Split STRING into a list of strings representing separate glyphs.
This takes into account combining characters and grapheme clusters:
if compositions are enabled, each sequence of characters composed
on display into a single grapheme cluster is treated as a single
indivisible unit."
(let ((result nil)
(start 0)
comp)
(while (< start (length string))
(if (setq comp (find-composition-internal
start
;; Don't search backward in the string for the
;; start of the composition.
(min (length string) (1+ start))
string nil))
(progn
(push (substring string (car comp) (cadr comp)) result)
(setq start (cadr comp)))
(push (substring string start (1+ start)) result)
(setq start (1+ start))))
(nreverse result)))