(lispref.info)Intro to Strings


Next: Predicates for Strings Up: Strings and Characters

Introduction to Strings and Characters
======================================

   Strings in Emacs Lisp are arrays that contain an ordered sequence of
characters.  Characters are represented in Emacs Lisp as integers;
whether an integer was intended as a character or not is determined only
by how it is used.  Thus, strings really contain integers.

   The length of a string (like any array) is fixed and independent of
the string contents, and cannot be altered.  Strings in Lisp are *not*
terminated by a distinguished character code.  (By contrast, strings in
C are terminated by a character with ASCII code 0.) This means that any
character, including the null character (ASCII code 0), is a valid
element of a string.

   Since strings are considered arrays, you can operate on them with the
general array functions.  (Note: Sequences Arrays Vectors.)  For
example, you can access or change individual characters in a string
using the functions `aref' and `aset' (Note: Array Functions.).

   Each character in a string is stored in a single byte.  Therefore,
numbers not in the range 0 to 255 are truncated when stored into a
string.  This means that a string takes up much less memory than a
vector of the same length.

   Sometimes key sequences are represented as strings.  When a string is
a key sequence, string elements in the range 128 to 255 represent meta
characters (which are extremely large integers) rather than keyboard
events in the range 128 to 255.

   Strings cannot hold characters that have the hyper, super or alt
modifiers; they can hold ASCII control characters, but no others.  They
do not distinguish case in ASCII control characters.  Note: Character
Type, for more information about representation of meta and other
modifiers for keyboard input characters.

   Like a buffer, a string can contain extents in it.  These extents are
created when a function such as `buffer-substring' is called on a
region with duplicable extents in it.  When the string is inserted into
a buffer, the extents are inserted along with it.  Note: Duplicable
Extents.

   Note: Text, for information about functions that display strings or
copy them into buffers.  Note: Character Type, and Note: String
Type, for information about the syntax of characters and strings.


automatically generated by info2www