/[cmucl]/src/code/string.lisp
ViewVC logotype

Diff of /src/code/string.lisp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.24 by rtoy, Tue Apr 20 17:57:45 2010 UTC revision 1.25 by rtoy, Mon Sep 13 21:27:04 2010 UTC
# Line 1684  Line 1684 
1684                              result :start (1+ start) :end next)))                              result :start (1+ start) :end next)))
1685            (write-string string result :start end :end offset-slen))))))            (write-string string result :start end :end offset-slen))))))
1686    
1687    
1688    ;; Some utilities
1689    (defun codepoints-string (seq)
1690      "Convert a sequence of codepoints to a string.  Codepoints outside
1691      the basic multilingual plane (BMP) are converted into the
1692      corresponding surrogate pairs."
1693      (with-output-to-string (s)
1694        (map nil #'(lambda (c)
1695                     (multiple-value-bind (hi lo)
1696                         (surrogates c)
1697                       (write-char hi s)
1698                       (when lo (write-char lo s))))
1699             seq)))
1700    
1701    (defun string-codepoints (s)
1702      "Convert a string to a list of corresponding code points.  Surrogate
1703      pairs in the string are converted into the correspoinding
1704      codepoint."
1705      (declare (type simple-string s))
1706      (let ((len (length s))
1707            cp)
1708        (do ((idx 0))
1709            ((>= idx len))
1710          (multiple-value-bind (c widep)
1711              (codepoint s idx)
1712            (if widep
1713                (incf idx 2)
1714                (incf idx))
1715            (push c cp)))
1716        (nreverse cp)))

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

  ViewVC Help
Powered by ViewVC 1.1.5