Changeset 5331
- Timestamp:
- Oct 9, 2006, 3:31:28 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ccl/level-1/l1-unicode.lisp (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/level-1/l1-unicode.lisp
r5321 r5331 39 39 (max-units-per-char 1) ;usually 1-4 40 40 41 ;; Returns NIL if the character can't be encoded, else writes it42 ;; to the stream and returns the number ofunits written.41 ;; Writes CHAR (or a replacement character if CHAR can't be encoded) 42 ;; to STREAM and returns the number of code-units written. 43 43 stream-encode-function ;(CHAR WRITE-FUNCTION STREAM) 44 44 45 ;; Returns a charcter or NIL, possibly calling a function to 46 ;; obtain the next unit from a stream-like argument 45 ;; Returns a charcter (possibly #\Replacement_Character) or :EOF. 47 46 stream-decode-function ;(1ST-UNIT NEXT-UNIT STREAM) 48 47 … … 144 143 (let* ((code (char-code char))) 145 144 (declare (type (mod #x110000) code)) 146 (when (< code 256) 147 (funcall write-function stream code) 148 1)))) 145 (if (>= code 256) 146 (setq code (char-code #\Sub))) 147 (funcall write-function stream code) 148 1))) 149 149 :stream-decode-function 150 150 (nfunction … … 236 236 237 237 :aliases '(:csASCII :cp637 :IBM637 :us :ISO646-US :ascii :ISO-ir-6) 238 239 238 :stream-encode-function 240 239 (nfunction … … 243 242 (let* ((code (char-code char))) 244 243 (declare (type (mod #x110000) code)) 245 (when (< code 128) 246 (funcall write-function stream code) 247 1)))) 244 (when (>= code 128) 245 (setq code (char-code #\Sub))) 246 (funcall write-function stream code) 247 1))) 248 248 :stream-decode-function 249 249 (nfunction … … 253 253 (type (unsigned-byte 8) 1st-unit)) 254 254 (if (< 1st-unit 128) 255 (code-char 1st-unit)))) 255 (code-char 1st-unit) 256 #\Replacement_Character))) 256 257 :vector-encode-function 257 258 (nfunction … … 434 435 435 436 (declare (type (mod #x110000) code)) 436 (when c2 437 (funcall write-function stream code) 438 1)))) 437 (funcall write-function stream (or c2 (char-code #\Sub))) 438 1))) 439 439 :stream-decode-function 440 440 (nfunction … … 637 637 (svref *unicode-2d8-2e0-to-iso8859-3* 638 638 (the fixnum (- code #x2d8))))))) 639 640 639 (declare (type (mod #x110000) code)) 641 (when c2 642 (funcall write-function stream code) 643 1)))) 640 (funcall write-function stream (or c2 (char-code #\Sub))) 641 1))) 644 642 :stream-decode-function 645 643 (nfunction … … 852 850 853 851 (declare (type (mod #x110000) code)) 854 (when c2 855 (funcall write-function stream code) 856 1)))) 852 (funcall write-function stream (or c2 (char-code #\Sub))) 853 1))) 857 854 :stream-decode-function 858 855 (nfunction … … 1031 1028 (logior 1032 1029 (the fixnum (ash (the fixnum (logand #x1f 1st-unit)) 6)) 1033 (the fixnum (logxor s1 #x80))))) 1034 (let* ((s2 (funcall next-unit-function stream))) 1030 (the fixnum (logxor s1 #x80)))) 1031 #\Replacement_Character) 1032 (let* ((s2 (funcall next-unit-function stream))) 1035 1033 (if (eq s2 :eof) 1036 1034 s2 … … 1051 1049 (ash (the fixnum (logand s1 #x3f)) 1052 1050 6)) 1053 (the fixnum (logand s2 #x3f)))))))) 1051 (the fixnum (logand s2 #x3f))))))) 1052 #\Replacement_Character) 1054 1053 (if (< 1st-unit #xf8) 1055 1054 (let* ((s3 (funcall next-unit-function stream))) … … 1075 1074 (the fixnum 1076 1075 (ash (the fixnum (logxor s2 #x80)) 6)) 1077 (the fixnum (logxor s3 #x80))))))))))))))))))))))) 1076 (the fixnum (logxor s3 #x80)))))) 1077 #\Replacement_Character)))) 1078 #\Replacement_Character))))))))))))) 1078 1079 :vector-encode-function 1079 1080 (nfunction … … 1382 1383 (- 1st-unit #xd800)) 1383 1384 10)) 1384 (the (unsigned-byte 10) (- 2nd-unit #xdc00)))))))))))) 1385 (the (unsigned-byte 10) (- 2nd-unit #xdc00))))) 1386 #\Replacement_Character))))))) 1385 1387 1386 1388 … … 1975 1977 (let* ((code (char-code char))) 1976 1978 (declare (type (mod #x110000) code)) 1977 (if ( <code #x10000)1978 ( progn1979 (funcall write-function stream code)1980 1))))1979 (if (>= code #x10000) 1980 (setq code (char-code #\Replacement_Character))) 1981 (funcall write-function stream code) 1982 1)) 1981 1983 1982 1984 (defun ucs-2-stream-decode (1st-unit next-unit-function stream) … … 1984 1986 (ignore next-unit-function stream)) 1985 1987 ;; CODE-CHAR returns NIL on either half of a surrogate pair. 1986 (code-char 1st-unit)) 1988 (or (code-char 1st-unit) 1989 #\Replacement_Character)) 1987 1990 1988 1991
Note:
See TracChangeset
for help on using the changeset viewer.
