Changeset 5321
- Timestamp:
- Oct 8, 2006, 7:29:36 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ccl/level-1/l1-unicode.lisp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/level-1/l1-unicode.lisp
r5294 r5321 1 ;; -*-Mode: LISP; Package: CCL -*-1 ;;;-*-Mode: LISP; Package: CCL -*- 2 2 ;;; 3 3 ;;; Copyright (C) 2006 Clozure Associates and contributors. … … 95 95 (aliases nil) 96 96 (documentation nil) 97 (encodable-limit char-code-limit) 97 98 ) 98 99 … … 227 228 nunits)) 228 229 :literal-char-code-limit 256 230 :encodable-limit 256 229 231 ) 230 232 231 232 233 (define-character-encoding :us-ascii 234 "An 7-bit, fixed-width character encoding in which all character 235 codes map to their Unicode equivalents. " 236 237 :aliases '(:csASCII :cp637 :IBM637 :us :ISO646-US :ascii :ISO-ir-6) 238 239 :stream-encode-function 240 (nfunction 241 ascii-stream-encode 242 (lambda (char write-function stream) 243 (let* ((code (char-code char))) 244 (declare (type (mod #x110000) code)) 245 (when (< code 128) 246 (funcall write-function stream code) 247 1)))) 248 :stream-decode-function 249 (nfunction 250 ascii-stream-decode 251 (lambda (1st-unit next-unit-function stream) 252 (declare (ignore next-unit-function stream) 253 (type (unsigned-byte 8) 1st-unit)) 254 (if (< 1st-unit 128) 255 (code-char 1st-unit)))) 256 :vector-encode-function 257 (nfunction 258 ascii-vector-encode 259 (lambda (string vector idx &optional (start 0) (end (length string))) 260 (declare (type (simple-array (unsigned-byte 8) (*)) vector) 261 (fixnum idx)) 262 (do* ((i start (1+ i))) 263 ((>= i end) idx) 264 (let* ((char (schar string i)) 265 (code (char-code char))) 266 (declare (type (mod #x110000) code)) 267 (if (>= code 128) 268 (return nil) 269 (progn 270 (setf (aref vector idx) code) 271 (incf idx))))))) 272 :vector-decode-function 273 (nfunction 274 ascii-vector-decode 275 (lambda (vector idx nunits string) 276 (declare (type (simple-array (unsigned-byte 8) (*)) vector)) 277 (do* ((i 0 (1+ i)) 278 (len (length vector)) 279 (index idx (1+ index))) 280 ((>= i nunits) (values string index)) 281 (if (>= index len) 282 (return (values nil idx)) 283 (let* ((code (aref vector index))) 284 (declare (type (unsigned-byte 8) code)) 285 (if (< code 128) 286 (setf (schar string i) code) 287 (return (values nil idx)))))))) 288 :memory-encode-function 289 (nfunction 290 ascii-memory-encode 291 (lambda (string pointer idx &optional (start 0) (end (length string))) 292 (do* ((i start (1+ i))) 293 ((>= i end) idx) 294 (let* ((code (char-code (schar string i)))) 295 (declare (type (mod #x110000) code)) 296 (if (>= code 128) 297 (return nil) 298 (progn 299 (setf (%get-unsigned-byte pointer idx) code) 300 (incf idx))))))) 301 :memory-decode-function 302 (nfunction 303 ascii-memory-decode 304 (lambda (pointer nunits idx string) 305 (do* ((i 0 (1+ i)) 306 (index idx (1+ index))) 307 ((>= i nunits) (values string index)) 308 (let* ((code (%get-unsigned-byte pointer index))) 309 (declare (type (unsigned-byte 8) code)) 310 (if (< code 128) 311 (setf (schar string i) (code-char code)) 312 (return (values nil idx))))))) 313 :units-in-string-function 314 (nfunction 315 ascii-units-in-string 316 (lambda (string &optional (start 0) (end (length string))) 317 (when (>= end start) 318 (do* ((i start (1+ i))) 319 ((= i end) (- end start)) 320 (let* ((code (char-code (schar string i)))) 321 (declare (type (mod #x110000) code)) 322 (unless (< code 128) (return nil))))))) 323 :length-of-vector-encoding-function 324 (nfunction 325 ascii-length-of-vector-encoding 326 (lambda (vector &optional (start 0) (end (length vector))) 327 (when (>= end start) 328 (do* ((i start (1+ i)) 329 (k 0 (1+ k))) 330 ((= i end) k) 331 (when (>= 128 (the (unsigned-byte 8) (aref vector i))) 332 (return nil)))))) 333 :length-of-memory-encoding-function 334 (nfunction 335 ascii-length-of-memory-encoding 336 (lambda (pointer nunits &optional (start 0)) 337 (do* ((i 0 (1+ i)) 338 (p start (1+ p))) 339 ((= i nunits) nunits) 340 (when (>= 128 (the (unsigned-byte 8) (%get-unsigned-byte pointer p))) 341 (return nil))))) 342 :literal-char-code-limit 128 343 :encodable-limit 128 344 ) 233 345 234 346 … … 827 939 :units-in-string-function 828 940 (nfunction 829 iso-8859- 1-units-in-string941 iso-8859-4-units-in-string 830 942 (lambda (string &optional (start 0) (end (length string))) 831 943 (when (>= end start) … … 1975 2087 native-ucs-2-length-of-vector-encoding 1976 2088 (lambda (vector &optional (start 0) (end (length vector))) 1977 (when (>= end start) 1978 (- end start)))) 2089 (do* ((i start (1+ i))) 2090 ((>= i end) (if (= i end) (- end start))) 2091 (let* ((code (aref vector i))) 2092 (unless (code-char code) 2093 (return nil)))))) 1979 2094 :length-of-memory-encoding-function 1980 2095 (nfunction 1981 2096 native-ucs-2-length-of-memory-encoding 1982 (lambda (pointer nunits &optional start)2097 (lambda (pointer nunits &optional (start 0)) 1983 2098 (declare (ignore pointer start)) 1984 2099 nunits))
Note:
See TracChangeset
for help on using the changeset viewer.
