
3 Using Characters and Strings
character. The following changes have been made to string data types to support double-byte characters:base-string corresponds to a string that consists entirely of base characters. If such a string is also a simple string, it is of typesimple-base-string. It is an error to store an extended character in a base string or in a simple base string.general-string and simple-general-string correspond to strings that can contain either base characters or extended characters.string-char is retained as an extension to Common Lisp. Note that characters with nonzero bits attributes cannot be stored in strings. If you know that your code uses only base characters, declare strings to be of typebase-string orsimple-base-string. Base strings use less storage than general strings, and simple base strings use less storage than either simple general strings or base strings.
;; Declare the string argument as a simple base string. (declare (simple-base-string string)) (schar string index))If you need to store extended characters in a string, you should declare strings to be of type
general-string orsimple-general-string.(defun fetch-kanji-char (string index) ;; Declare the string argument as a simple general string. declare (simple-general-string string)) (schar string index))For simple base strings and simple general strings, you can use the functions
sbchar andsgchar instead of the Common Lisp functionschar to extract characters. See the reference pages for sbchar and sgchar for complete descriptions of these functions.;;; This expression compiles to the same code as ;;; FETCH-ASCII-CHAR. (defun fetch-ascii-char-2 (string index) ;; Assume string is always a base string. (sbchar string index));;; This expression compiles to the same code as ;;; FETCH-KANJI-CHAR. (defun fetch-kanji-char-2 (string index) ;; Assume string is always a general string. (sgchar string index))

Generated with Harlequin WebMaker