[cmucl-imp] string-to-octets
Helmut Eller
heller at common-lisp.net
Sun Oct 30 19:28:38 CET 2011
* 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.
Helmut
More information about the cmucl-imp
mailing list