44 |
The length of a string (like any array) is fixed, and cannot be |
The length of a string (like any array) is fixed, and cannot be |
45 |
altered once the string exists. Strings in Lisp are @emph{not} |
altered once the string exists. Strings in Lisp are @emph{not} |
46 |
terminated by a distinguished character code. (By contrast, strings in |
terminated by a distinguished character code. (By contrast, strings in |
47 |
C are terminated by a character with @sc{ascii} code 0.) |
C are terminated by a character with @acronym{ASCII} code 0.) |
48 |
|
|
49 |
Since strings are arrays, and therefore sequences as well, you can |
Since strings are arrays, and therefore sequences as well, you can |
50 |
operate on them with the general array and sequence functions. |
operate on them with the general array and sequence functions. |
52 |
change individual characters in a string using the functions @code{aref} |
change individual characters in a string using the functions @code{aref} |
53 |
and @code{aset} (@pxref{Array Functions}). |
and @code{aset} (@pxref{Array Functions}). |
54 |
|
|
55 |
There are two text representations for non-@sc{ascii} characters in |
There are two text representations for non-@acronym{ASCII} characters in |
56 |
Emacs strings (and in buffers): unibyte and multibyte (@pxref{Text |
Emacs strings (and in buffers): unibyte and multibyte (@pxref{Text |
57 |
Representations}). An @sc{ascii} character always occupies one byte in a |
Representations}). An @acronym{ASCII} character always occupies one byte in a |
58 |
string; in fact, when a string is all @sc{ascii}, there is no real |
string; in fact, when a string is all @acronym{ASCII}, there is no real |
59 |
difference between the unibyte and multibyte representations. |
difference between the unibyte and multibyte representations. |
60 |
For most Lisp programming, you don't need to be concerned with these two |
For most Lisp programming, you don't need to be concerned with these two |
61 |
representations. |
representations. |
66 |
codes in the range 128 to 255. |
codes in the range 128 to 255. |
67 |
|
|
68 |
Strings cannot hold characters that have the hyper, super or alt |
Strings cannot hold characters that have the hyper, super or alt |
69 |
modifiers; they can hold @sc{ascii} control characters, but no other |
modifiers; they can hold @acronym{ASCII} control characters, but no other |
70 |
control characters. They do not distinguish case in @sc{ascii} control |
control characters. They do not distinguish case in @acronym{ASCII} control |
71 |
characters. If you want to store such characters in a sequence, such as |
characters. If you want to store such characters in a sequence, such as |
72 |
a key sequence, you must use a vector instead of a string. |
a key sequence, you must use a vector instead of a string. |
73 |
@xref{Character Type}, for more information about the representation of meta |
@xref{Character Type}, for more information about the representation of meta |
417 |
strings. When @code{equal} (@pxref{Equality Predicates}) compares two |
strings. When @code{equal} (@pxref{Equality Predicates}) compares two |
418 |
strings, it uses @code{string=}. |
strings, it uses @code{string=}. |
419 |
|
|
420 |
If the strings contain non-@sc{ascii} characters, and one is unibyte |
If the strings contain non-@acronym{ASCII} characters, and one is unibyte |
421 |
while the other is multibyte, then they cannot be equal. @xref{Text |
while the other is multibyte, then they cannot be equal. @xref{Text |
422 |
Representations}. |
Representations}. |
423 |
@end defun |
@end defun |
439 |
|
|
440 |
Pairs of characters are compared according to their character codes. |
Pairs of characters are compared according to their character codes. |
441 |
Keep in mind that lower case letters have higher numeric values in the |
Keep in mind that lower case letters have higher numeric values in the |
442 |
@sc{ascii} character set than their upper case counterparts; digits and |
@acronym{ASCII} character set than their upper case counterparts; digits and |
443 |
many punctuation characters have a lower numeric value than upper case |
many punctuation characters have a lower numeric value than upper case |
444 |
letters. An @sc{ascii} character is less than any non-@sc{ascii} |
letters. An @acronym{ASCII} character is less than any non-@acronym{ASCII} |
445 |
character; a unibyte non-@sc{ascii} character is always less than any |
character; a unibyte non-@acronym{ASCII} character is always less than any |
446 |
multibyte non-@sc{ascii} character (@pxref{Text Representations}). |
multibyte non-@acronym{ASCII} character (@pxref{Text Representations}). |
447 |
|
|
448 |
@example |
@example |
449 |
@group |
@group |
551 |
@cindex string to character |
@cindex string to character |
552 |
This function returns the first character in @var{string}. If the |
This function returns the first character in @var{string}. If the |
553 |
string is empty, the function returns 0. The value is also 0 when the |
string is empty, the function returns 0. The value is also 0 when the |
554 |
first character of @var{string} is the null character, @sc{ascii} code |
first character of @var{string} is the null character, @acronym{ASCII} code |
555 |
0. |
0. |
556 |
|
|
557 |
@example |
@example |
846 |
The character case functions change the case of single characters or |
The character case functions change the case of single characters or |
847 |
of the contents of strings. The functions normally convert only |
of the contents of strings. The functions normally convert only |
848 |
alphabetic characters (the letters @samp{A} through @samp{Z} and |
alphabetic characters (the letters @samp{A} through @samp{Z} and |
849 |
@samp{a} through @samp{z}, as well as non-@sc{ascii} letters); other |
@samp{a} through @samp{z}, as well as non-@acronym{ASCII} letters); other |
850 |
characters are not altered. You can specify a different case |
characters are not altered. You can specify a different case |
851 |
conversion mapping by specifying a case table (@pxref{Case Tables}). |
conversion mapping by specifying a case table (@pxref{Case Tables}). |
852 |
|
|
854 |
arguments. |
arguments. |
855 |
|
|
856 |
The examples below use the characters @samp{X} and @samp{x} which have |
The examples below use the characters @samp{X} and @samp{x} which have |
857 |
@sc{ascii} codes 88 and 120 respectively. |
@acronym{ASCII} codes 88 and 120 respectively. |
858 |
|
|
859 |
@defun downcase string-or-char |
@defun downcase string-or-char |
860 |
This function converts a character or a string to lower case. |
This function converts a character or a string to lower case. |
1001 |
|
|
1002 |
The extra table @var{equivalences} is a map that cyclicly permutes |
The extra table @var{equivalences} is a map that cyclicly permutes |
1003 |
each equivalence class (of characters with the same canonical |
each equivalence class (of characters with the same canonical |
1004 |
equivalent). (For ordinary @sc{ascii}, this would map @samp{a} into |
equivalent). (For ordinary @acronym{ASCII}, this would map @samp{a} into |
1005 |
@samp{A} and @samp{A} into @samp{a}, and likewise for each set of |
@samp{A} and @samp{A} into @samp{a}, and likewise for each set of |
1006 |
equivalent characters.) |
equivalent characters.) |
1007 |
|
|
1038 |
@end defun |
@end defun |
1039 |
|
|
1040 |
The following three functions are convenient subroutines for packages |
The following three functions are convenient subroutines for packages |
1041 |
that define non-@sc{ascii} character sets. They modify the specified |
that define non-@acronym{ASCII} character sets. They modify the specified |
1042 |
case table @var{case-table}; they also modify the standard syntax table. |
case table @var{case-table}; they also modify the standard syntax table. |
1043 |
@xref{Syntax Tables}. Normally you would use these functions to change |
@xref{Syntax Tables}. Normally you would use these functions to change |
1044 |
the standard case table. |
the standard case table. |