Re: string-to-octets
Helmut Eller <[email protected]> Sun, 30 Oct 2011 23:40:17 +0100
| Newsgroups | gmane.lisp.cmucl.devel |
|---|---|
| Message-ID | <[email protected]> |
* Helmut Eller [2011-10-30 18:28] writes: > * Raymond Toy [2011-10-30 16:30] writes: > >>> I'm not sure that I understand the purpose of the 18. Is this something >>> that is needed later? >> >> Yeah, that was kind of messy. This is what I currently have: >> >> * (let ((buffer (make-array 20 :element-type '(unsigned-byte 8))) >> (string (make-string 100 :initial-element #\u+f012))) >> (stream:string-to-octets string :external-format :utf8 :buffer >> buffer)) >> >> #(239 128 146 239 128 146 239 128 146 239 128 146 239 128 146 239 128 >> 146 239 >> 128) >> 18 >> 6 >> >> So 18 is the number of valid octets actually written. (The last two >> octets form an incomplete conversion.) The 6 is the number of >> characters consumed to produce those 18 octets. >> >> For the case where no buffer is specified, a new buffer is created and >> the second return value is the number of octets written (same as the >> buffer length), and the third value is the number of characters (length >> of the string). >> >> Is that better? > > Yes, looks good. BTW, it would also be useful to have a parameter to specify a start position in buffer. With that it would be possible to buffer up multiple small chunks. Helmut _______________________________________________ cmucl-imp mailing list [email protected] http://lists.zs64.net/mailman/listinfo/cmucl-imp