Changeset 6560


Ignore:
Timestamp:
May 16, 2007, 8:33:51 AM (15 years ago)
Author:
gb
Message:

Add STRING-ENCODED-LENGTH-IN-BYTES. Make it,
CSTRING-ENCODED-LENGTH-IN-BYTES, and ENCODE-STRING-FROM-MEMORY
deal with non-simple strings.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/level-1/l1-unicode.lisp

    r6554 r6560  
    46154615     
    46164616                             
    4617                                      
     4617(defun string-encoded-length-in-bytes (encoding string start end)
     4618  (if (typep string 'simple-base-string)
     4619    (funcall (character-encoding-octets-in-string-function encoding)
     4620             string
     4621             (or start 0)
     4622             (or end (length string)))
     4623    (let* ((s (string string)))
     4624      (multiple-value-bind (data offset) (array-data-and-offset s)
     4625        (funcall (character-encoding-octets-in-string-function encoding)
     4626                 data
     4627                 (+ offset (or start 0))
     4628                 (+ offset (or end (length s))))))))
     4629
     4630;;; Same as above, but add the length of a trailing 0 code-unit.
    46184631(defun cstring-encoded-length-in-bytes (encoding string start end)
    4619   (+ (length (character-encoding-nul-encoding encoding))                             ; NUL terminator
    4620      (funcall (character-encoding-octets-in-string-function encoding)
    4621               string
    4622               (or start 0)
    4623               (or end (length string)))))
    4624 
    4625 
     4632  (+ (ash (character-encoding-code-unit-size encoding) -3) ; NUL terminator
     4633     (string-encoded-length-in-bytes string start end)))
     4634
     4635                   
    46264636
    46274637(defun encode-string-to-memory (encoding pointer offset string start end)
    4628   (funcall (character-encoding-memory-encode-function encoding)
    4629            string pointer offset (or start 0) (or end (length string))))
     4638  (if (typep string 'simple-base-string)
     4639    (funcall (character-encoding-memory-encode-function encoding)
     4640             string pointer offset (or start 0) (or end (length string)))
     4641    (let* ((s (string string)))
     4642      (multiple-value-bind (data data-offset)
     4643          (array-data-and-offset s)
     4644        (funcall (character-encoding-memory-encode-function encoding)
     4645                 data pointer offset (+ data-offset (or start 0)) (+ data-offset (or end (length s))))))))
     4646     
Note: See TracChangeset for help on using the changeset viewer.