161 |
@node Integer Type |
@node Integer Type |
162 |
@subsection Integer Type |
@subsection Integer Type |
163 |
|
|
164 |
The range of values for integers in Emacs Lisp is @minus{}134217728 to |
The range of values for integers in Emacs Lisp is @minus{}268435456 to |
165 |
134217727 (28 bits; i.e., |
268435455 (29 bits; i.e., |
166 |
@ifnottex |
@ifnottex |
167 |
-2**27 |
-2**28 |
168 |
@end ifnottex |
@end ifnottex |
169 |
@tex |
@tex |
170 |
@math{-2^{27}} |
@math{-2^{28}} |
171 |
@end tex |
@end tex |
172 |
to |
to |
173 |
@ifnottex |
@ifnottex |
174 |
2**27 - 1) |
2**28 - 1) |
175 |
@end ifnottex |
@end ifnottex |
176 |
@tex |
@tex |
177 |
@math{2^{28}-1}) |
@math{2^{28}-1}) |
178 |
@end tex |
@end tex |
179 |
on most machines. (Some machines may provide a wider range.) It is |
on most machines. (Some machines may provide a wider range.) It is |
180 |
important to note that the Emacs Lisp arithmetic functions do not check |
important to note that the Emacs Lisp arithmetic functions do not check |
181 |
for overflow. Thus @code{(1+ 134217727)} is @minus{}134217728 on most |
for overflow. Thus @code{(1+ 268435455)} is @minus{}268435456 on most |
182 |
machines. |
machines. |
183 |
|
|
184 |
The read syntax for integers is a sequence of (base ten) digits with an |
The read syntax for integers is a sequence of (base ten) digits with an |
192 |
1 ; @r{The integer 1.} |
1 ; @r{The integer 1.} |
193 |
1. ; @r{Also the integer 1.} |
1. ; @r{Also the integer 1.} |
194 |
+1 ; @r{Also the integer 1.} |
+1 ; @r{Also the integer 1.} |
195 |
268435457 ; @r{Also the integer 1 on a 28-bit implementation.} |
536870913 ; @r{Also the integer 1 on a 29-bit implementation.} |
196 |
@end group |
@end group |
197 |
@end example |
@end example |
198 |
|
|
216 |
|
|
217 |
@node Character Type |
@node Character Type |
218 |
@subsection Character Type |
@subsection Character Type |
219 |
@cindex @sc{ascii} character codes |
@cindex @acronym{ASCII} character codes |
220 |
|
|
221 |
A @dfn{character} in Emacs Lisp is nothing more than an integer. In |
A @dfn{character} in Emacs Lisp is nothing more than an integer. In |
222 |
other words, characters are represented by their character codes. For |
other words, characters are represented by their character codes. For |
228 |
|
|
229 |
Characters in strings, buffers, and files are currently limited to the |
Characters in strings, buffers, and files are currently limited to the |
230 |
range of 0 to 524287---nineteen bits. But not all values in that range |
range of 0 to 524287---nineteen bits. But not all values in that range |
231 |
are valid character codes. Codes 0 through 127 are @sc{ascii} codes; the |
are valid character codes. Codes 0 through 127 are @acronym{ASCII} codes; the |
232 |
rest are non-@sc{ascii} (@pxref{Non-ASCII Characters}). Characters that represent |
rest are non-@acronym{ASCII} (@pxref{Non-ASCII Characters}). Characters that represent |
233 |
keyboard input have a much wider range, to encode modifier keys such as |
keyboard input have a much wider range, to encode modifier keys such as |
234 |
Control, Meta and Shift. |
Control, Meta and Shift. |
235 |
|
|
323 |
@end example |
@end example |
324 |
|
|
325 |
In strings and buffers, the only control characters allowed are those |
In strings and buffers, the only control characters allowed are those |
326 |
that exist in @sc{ascii}; but for keyboard input purposes, you can turn |
that exist in @acronym{ASCII}; but for keyboard input purposes, you can turn |
327 |
any character into a control character with @samp{C-}. The character |
any character into a control character with @samp{C-}. The character |
328 |
codes for these non-@sc{ascii} control characters include the |
codes for these non-@acronym{ASCII} control characters include the |
329 |
@tex |
@tex |
330 |
@math{2^{26}} |
@math{2^{26}} |
331 |
@end tex |
@end tex |
333 |
2**26 |
2**26 |
334 |
@end ifnottex |
@end ifnottex |
335 |
bit as well as the code for the corresponding non-control |
bit as well as the code for the corresponding non-control |
336 |
character. Ordinary terminals have no way of generating non-@sc{ascii} |
character. Ordinary terminals have no way of generating non-@acronym{ASCII} |
337 |
control characters, but you can generate them straightforwardly using X |
control characters, but you can generate them straightforwardly using X |
338 |
and other window systems. |
and other window systems. |
339 |
|
|
365 |
@ifnottex |
@ifnottex |
366 |
2**27 |
2**27 |
367 |
@end ifnottex |
@end ifnottex |
368 |
bit set (which on most machines makes it a negative number). We |
bit set. We use high bits for this and other modifiers to make |
369 |
use high bits for this and other modifiers to make possible a wide range |
possible a wide range of basic character codes. |
|
of basic character codes. |
|
370 |
|
|
371 |
In a string, the |
In a string, the |
372 |
@tex |
@tex |
375 |
@ifnottex |
@ifnottex |
376 |
2**7 |
2**7 |
377 |
@end ifnottex |
@end ifnottex |
378 |
bit attached to an @sc{ascii} character indicates a meta character; thus, the |
bit attached to an @acronym{ASCII} character indicates a meta character; thus, the |
379 |
meta characters that can fit in a string have codes in the range from |
meta characters that can fit in a string have codes in the range from |
380 |
128 to 255, and are the meta versions of the ordinary @sc{ascii} |
128 to 255, and are the meta versions of the ordinary @acronym{ASCII} |
381 |
characters. (In Emacs versions 18 and older, this convention was used |
characters. (In Emacs versions 18 and older, this convention was used |
382 |
for characters outside of strings as well.) |
for characters outside of strings as well.) |
383 |
|
|
389 |
@samp{?\M-\C-b}, @samp{?\C-\M-b}, or @samp{?\M-\002}. |
@samp{?\M-\C-b}, @samp{?\C-\M-b}, or @samp{?\M-\002}. |
390 |
|
|
391 |
The case of a graphic character is indicated by its character code; |
The case of a graphic character is indicated by its character code; |
392 |
for example, @sc{ascii} distinguishes between the characters @samp{a} |
for example, @acronym{ASCII} distinguishes between the characters @samp{a} |
393 |
and @samp{A}. But @sc{ascii} has no way to represent whether a control |
and @samp{A}. But @acronym{ASCII} has no way to represent whether a control |
394 |
character is upper case or lower case. Emacs uses the |
character is upper case or lower case. Emacs uses the |
395 |
@tex |
@tex |
396 |
@math{2^{25}} |
@math{2^{25}} |
432 |
mark followed by a backslash and the octal character code (up to three |
mark followed by a backslash and the octal character code (up to three |
433 |
octal digits); thus, @samp{?\101} for the character @kbd{A}, |
octal digits); thus, @samp{?\101} for the character @kbd{A}, |
434 |
@samp{?\001} for the character @kbd{C-a}, and @code{?\002} for the |
@samp{?\001} for the character @kbd{C-a}, and @code{?\002} for the |
435 |
character @kbd{C-b}. Although this syntax can represent any @sc{ascii} |
character @kbd{C-b}. Although this syntax can represent any @acronym{ASCII} |
436 |
character, it is preferred only when the precise octal value is more |
character, it is preferred only when the precise octal value is more |
437 |
important than the @sc{ascii} representation. |
important than the @acronym{ASCII} representation. |
438 |
|
|
439 |
@example |
@example |
440 |
@group |
@group |
915 |
@end example |
@end example |
916 |
|
|
917 |
@node Non-ASCII in Strings |
@node Non-ASCII in Strings |
918 |
@subsubsection Non-@sc{ascii} Characters in Strings |
@subsubsection Non-@acronym{ASCII} Characters in Strings |
919 |
|
|
920 |
You can include a non-@sc{ascii} international character in a string |
You can include a non-@acronym{ASCII} international character in a string |
921 |
constant by writing it literally. There are two text representations |
constant by writing it literally. There are two text representations |
922 |
for non-@sc{ascii} characters in Emacs strings (and in buffers): unibyte |
for non-@acronym{ASCII} characters in Emacs strings (and in buffers): unibyte |
923 |
and multibyte. If the string constant is read from a multibyte source, |
and multibyte. If the string constant is read from a multibyte source, |
924 |
such as a multibyte buffer or string, or a file that would be visited as |
such as a multibyte buffer or string, or a file that would be visited as |
925 |
multibyte, then the character is read as a multibyte character, and that |
multibyte, then the character is read as a multibyte character, and that |
927 |
unibyte source, then the character is read as unibyte and that makes the |
unibyte source, then the character is read as unibyte and that makes the |
928 |
string unibyte. |
string unibyte. |
929 |
|
|
930 |
You can also represent a multibyte non-@sc{ascii} character with its |
You can also represent a multibyte non-@acronym{ASCII} character with its |
931 |
character code: use a hex escape, @samp{\x@var{nnnnnnn}}, with as many |
character code: use a hex escape, @samp{\x@var{nnnnnnn}}, with as many |
932 |
digits as necessary. (Multibyte non-@sc{ascii} character codes are all |
digits as necessary. (Multibyte non-@acronym{ASCII} character codes are all |
933 |
greater than 256.) Any character which is not a valid hex digit |
greater than 256.) Any character which is not a valid hex digit |
934 |
terminates this construct. If the next character in the string could be |
terminates this construct. If the next character in the string could be |
935 |
interpreted as a hex digit, write @w{@samp{\ }} (backslash and space) to |
interpreted as a hex digit, write @w{@samp{\ }} (backslash and space) to |
939 |
character to the string, but it does terminate the preceding hex escape. |
character to the string, but it does terminate the preceding hex escape. |
940 |
|
|
941 |
Using a multibyte hex escape forces the string to multibyte. You can |
Using a multibyte hex escape forces the string to multibyte. You can |
942 |
represent a unibyte non-@sc{ascii} character with its character code, |
represent a unibyte non-@acronym{ASCII} character with its character code, |
943 |
which must be in the range from 128 (0200 octal) to 255 (0377 octal). |
which must be in the range from 128 (0200 octal) to 255 (0377 octal). |
944 |
This forces a unibyte string. |
This forces a unibyte string. |
945 |
|
|
958 |
|
|
959 |
However, not all of the characters you can write with backslash |
However, not all of the characters you can write with backslash |
960 |
escape-sequences are valid in strings. The only control characters that |
escape-sequences are valid in strings. The only control characters that |
961 |
a string can hold are the @sc{ascii} control characters. Strings do not |
a string can hold are the @acronym{ASCII} control characters. Strings do not |
962 |
distinguish case in @sc{ascii} control characters. |
distinguish case in @acronym{ASCII} control characters. |
963 |
|
|
964 |
Properly speaking, strings cannot hold meta characters; but when a |
Properly speaking, strings cannot hold meta characters; but when a |
965 |
string is to be used as a key sequence, there is a special convention |
string is to be used as a key sequence, there is a special convention |
966 |
that provides a way to represent meta versions of @sc{ascii} characters in a |
that provides a way to represent meta versions of @acronym{ASCII} characters in a |
967 |
string. If you use the @samp{\M-} syntax to indicate a meta character |
string. If you use the @samp{\M-} syntax to indicate a meta character |
968 |
in a string constant, this sets the |
in a string constant, this sets the |
969 |
@tex |
@tex |
1877 |
Comparison of strings is case-sensitive, but does not take account of |
Comparison of strings is case-sensitive, but does not take account of |
1878 |
text properties---it compares only the characters in the strings. |
text properties---it compares only the characters in the strings. |
1879 |
A unibyte string never equals a multibyte string unless the |
A unibyte string never equals a multibyte string unless the |
1880 |
contents are entirely @sc{ascii} (@pxref{Text Representations}). |
contents are entirely @acronym{ASCII} (@pxref{Text Representations}). |
1881 |
|
|
1882 |
@example |
@example |
1883 |
@group |
@group |