Elisp: Join Strings, Codepoints to String
Join Strings
concat
-
(concat &rest str1 str2 etc)
join strings.
(concat "some" "thing")
Codepoints to String
use concat
Any arg can be a List or Vector, but each element must be a integer, each is the Codepoint of a char. 〔see Elisp: Character Type〕
;; if arg is vector or list, their elements must be integers, as codepoints for char (concat (vector 97 98 99)) ;; "abc" (concat (list 32)) ;; " " ;; 32 is space (concat (vector 97 98 99 ) (list 32) "thing") ;; "abc thing" ;; this is an error of wrong-type-argument ;; (concat (vector "a" "b" ) "thing")
List of Strings to String, with Separators
mapconcat
-
(mapconcat function sequence separator)
Convert strings in a Sequence to a single string, with separator between them, also map a function to each.
;; list of numbers to string (mapconcat 'number-to-string '(1 2 3) ",") ;; "1,2,3"
;; list to string (mapconcat 'identity '("a" "b" "c") ",") ;; "a,b,c"
;; vector to string (mapconcat 'number-to-string [1 2 3] ",") ;; "1,2,3"
Other Join String Functions
format
→ join by embedding into arbitrary text. Elisp: Format String
byte-to-string