Changeset 5251


Ignore:
Timestamp:
Sep 24, 2006, 3:29:12 AM (18 years ago)
Author:
Gary Byers
Message:

CHAR-NAME looks in the *CHARACTER-NAMES* array if the code is within its bounds.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/lib/chars.lisp

    r5183 r5251  
    280280(defun char-name (c)
    281281  "Return the name (a STRING) for a CHARACTER object."
    282   (dolist (e *name-char-alist*)
    283     (declare (list e))   
    284     (when (eq c (cdr e))(return-from char-name (car e))))
    285   (let ((code (char-code c)))
    286     (declare (fixnum code))
    287     (cond ((< code #x7f)
    288            (when (< code (char-code #\space))
    289              (let ((str (make-string 2 :element-type 'base-char)))
    290                (declare (simple-base-string str))
    291                (setf (schar str 0) #\^)
    292                (setf (schar str 1)(code-char (%ilogxor code #x40)))
    293                str)))
    294           ((and (< code #x100)(graphic-char-p c)) nil)
    295           (t (format nil "U+~x" code)))))
     282  (let* ((code (char-code c)))
     283    (declare (type (mod #x110000) code))
     284    (or (and (< code (length *character-names*))
     285             (svref *character-names* code))
     286        (cond ((< code #x7f)
     287               (when (< code (char-code #\space))
     288                 (let ((str (make-string 2 :element-type 'base-char)))
     289                   (declare (simple-base-string str))
     290                   (setf (schar str 0) #\^)
     291                   (setf (schar str 1)(code-char (%ilogxor code #x40)))
     292                   str)))
     293              ((and (< code #x100)(graphic-char-p c)) nil)
     294              (t (format nil "U+~x" code))))))
    296295
    297296
Note: See TracChangeset for help on using the changeset viewer.