[cl-pdf-devel] switching to binary format
Marc Battyani
marc.battyani at fractalconcept.com
Fri Mar 18 17:13:31 UTC 2005
"Dmitriy Ivanov" <divanov at aha.ru> wrote:
> |> BTW, I have just updated my contribution di-pdf.lisp at lisp.ystok.ru.
> |
> | OK from a first look you are still using write-string and format on the
> | binary stream. I don't think this will work on other implementations.
>
> No wonder - the code is LispWorks biased. I always
> - open files with :element-type '(unsigned-byte 8);
> - for non-base characters, invoke
> (write-byte (ef:char-external-code char *pdf-code-page*)
> *pdf-stream*));
>
> - for base characters, invoke write-char or write-sequence, which are
> accepted by LispWorks bivalent streams.
>
> I suggest following these guidelines in pursuance of compatibility.
>
> 1. (deftype octet () '(unsigned-byte 8))
>
> 2. In CL-PDF code, use only write byte or write-sequence that is always
> given an array of type (vector octet) as an argument.
>
> 3. To convert to (vector octet),
> - either introduce a kind of write-pdf-string and format-pdf functions
> - or use acl-compat.excl:string-to-octets explicitly.
Hello Dmitri,
I also use LW so it's easy enough for me. But I would just prefer to avoid
to break cl-pdf on every other implementation.
If there already exist a portable function to convert string to octets then
maybe the performance hit will not be a problem.
I looked at acl-compat.excl:string-to-octets but for LW the conversion
function just makes the conversion "manually" it's not an optimized
function:
(loop for from-index from start below end
for to-index upfrom 0
do (progn
(setf (aref mb-vector to-index)
(char-code (aref string from-index)))))
I don't know why there is a progn.
Maybe I should just try and see how it works...
Marc
More information about the cl-pdf-devel
mailing list