[cl-pdf-devel] pdf-string don't work with unicode strings in sbcl
Andrey Moskvitin
archimag at gmail.com
Wed Apr 29 12:33:03 UTC 2009
Hi,
In SBCL result of the expression (type-of (code-char 244)) is extended-char,
so pdf-string can not handle unicode strings. See my patch.
Moskvitin Andrey
---
diff --git a/pdf.lisp b/pdf.lisp
index 16d8f6f..b54b5a6 100644
--- a/pdf.lisp
+++ b/pdf.lisp
@@ -235,21 +235,20 @@
(setq unicode (notevery #+lispworks #'lw:base-char-p
#-lispworks (lambda (char) (<= (char-code
char) 255))
string)))
- (with-output-to-string (stream nil :element-type 'base-char)
- (write-char #\( stream)
- (when unicode ; write the Unicode byte order marker U+FEFF
- (write-char #.(code-char 254) stream) (write-char #.(code-char 255)
stream))
+ (with-output-to-string (stream nil :element-type 'base-char)
+ (if unicode
+ (write-string "<FEFF" stream)
+ (write-char #\( stream))
(loop for char across string
for code = (char-code char)
if unicode
- do (write-char (code-char (ldb (byte 8 8) code)) stream) ;
hi
- (write-char (code-char (ldb (byte 8 0) code)) stream) ;
lo
+ do (format stream "~4,'0x" code)
else if (> code 255)
do (write-char (code-char (ldb (byte 8 0) code)) stream) ;
lo
else do (case char ((#\( #\) #\\)
(write-char #\\ stream)))
(write-char char stream))
- (write-char #\) stream))))
+ (write-char (if unicode #\> #\)) stream))))
(defmacro with-outline-level ((title ref-name) &body body)
`(unwind-protect
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cl-pdf-devel/attachments/20090429/5c80664a/attachment.html>
More information about the cl-pdf-devel
mailing list