The character case functions change the case of single characters or of the contents of strings. The functions convert only alphabetic characters (the letters ‘A’ through ‘Z’ and ‘a’ through ‘z’); other characters are not altered. The functions do not modify the strings that are passed to them as arguments.
The examples below use the characters ‘X’ and ‘x’ which have ascii codes 88 and 120 respectively.
This function converts a character or a string to lower case.
When the argument to
downcaseis a string, the function creates and returns a new string in which each letter in the argument that is upper case is converted to lower case. When the argument todowncaseis a character,downcasereturns the corresponding lower case character. (This value is actually an integer under XEmacs 19.) If the original character is lower case, or is not a letter, then the value equals the original character.Optional second arg buffer specifies which buffer's case tables to use, and defaults to the current buffer.
(downcase "The cat in the hat") ⇒ "the cat in the hat" (downcase ?X) ⇒ ?x ;; Under SXEmacs. ⇒ 120 ;; Under XEmacs 19.
This function converts a character or a string to upper case.
When the argument to
upcaseis a string, the function creates and returns a new string in which each letter in the argument that is lower case is converted to upper case.When the argument to
upcaseis a character,upcasereturns the corresponding upper case character. (This value is actually an integer under XEmacs 19.) If the original character is upper case, or is not a letter, then the value equals the original character.Optional second arg buffer specifies which buffer's case tables to use, and defaults to the current buffer.
(upcase "The cat in the hat") ⇒ "THE CAT IN THE HAT" (upcase ?x) ⇒ ?X ;; Under SXEmacs. ⇒ 88 ;; Under XEmacs 19.
This function capitalizes strings or characters. If string-or-char is a string, the function creates and returns a new string, whose contents are a copy of string-or-char in which each word has been capitalized. This means that the first character of each word is converted to upper case, and the rest are converted to lower case.
The definition of a word is any sequence of consecutive characters that are assigned to the word constituent syntax class in the current syntax table (see Syntax Class Table).
When the argument to
capitalizeis a character,capitalizehas the same result asupcase.Optional second arg buffer specifies which buffer's case tables to use, and defaults to the current buffer.
(capitalize "The cat in the hat") ⇒ "The Cat In The Hat" (capitalize "THE 77TH-HATTED CAT") ⇒ "The 77th-Hatted Cat" (capitalize ?x) ⇒ ?X ;; Under SXEmacs. ⇒ 88 ;; Under XEmacs 19.