GNU Emacs Lisp Reference Manual
This section describes functions for conversions between characters,
strings and integers. format and prin1-to-string
(see Output Functions) can also convert Lisp objects into strings.
read-from-string (see Input Functions) can ``convert'' a
string representation of a Lisp object into an object.
See Documentation, for functions that produce textual descriptions
of text characters and general input events
(single-key-description and text-char-description). These
functions are used primarily for making help messages.
This function is similar to make-string with an integer argument
of 1. (See Creating Strings.) This conversion can also be done with
format using the %c format specification.
(See Formatting Strings.)
(char-to-string ?x)
=> "x"
(char-to-string (+ 256 ?x))
=> "x"
(make-string 1 ?x)
=> "x"
(string-to-char "ABC")
=> 65
(string-to-char "xyz")
=> 120
(string-to-char "")
=> 0
(string-to-char "\000")
=> 0
This function may be eliminated in the future if it does not seem useful enough to retain.
(number-to-string 256)
=> "256"
(number-to-string -23)
=> "-23"
(number-to-string -23.5)
=> "-23.5"
int-to-string is a semi-obsolete alias for this function.
See also the function format in Formatting Strings.
(string-to-number "256")
=> 256
(string-to-number "25 is a perfect square.")
=> 25
(string-to-number "X256")
=> 0
(string-to-number "-4.5")
=> -4.5
string-to-int is an obsolete alias for this function.