Jeffrey Massung
2014-07-20 22:21:01 UTC
Okay, I feel like a dolt, but this is something that's always eluded me
in CL. How do I write unicode (well, specifically multibyte) characters
to a file?
For example:
(with-output-to-string (s)
(princ #\u+2022 s))
Error: Cannot write SIMPLE-CHAR into stream.
Makes sense. So...
(with-output-to-string (s nil :element-type 'character)
(princ #\u+2022 s))
"•"
Success. Let's try the same thing with a file, though:
(with-open-file (s #p"~/test.txt" :element-type 'character :direction
:output)
(princ #\u+2022 s))
Error: Cannot write SIMPLE-CHAR into stream.
I've never been able to use with-open-file to create a "character"
stream for any character class other than a base-char. How do I do this? :-)
Thanks!
Jeff M.
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-***@lispworks.com
http://www.lispworks.com/support/lisp-hug.html
in CL. How do I write unicode (well, specifically multibyte) characters
to a file?
For example:
(with-output-to-string (s)
(princ #\u+2022 s))
Error: Cannot write SIMPLE-CHAR into stream.
Makes sense. So...
(with-output-to-string (s nil :element-type 'character)
(princ #\u+2022 s))
"•"
Success. Let's try the same thing with a file, though:
(with-open-file (s #p"~/test.txt" :element-type 'character :direction
:output)
(princ #\u+2022 s))
Error: Cannot write SIMPLE-CHAR into stream.
I've never been able to use with-open-file to create a "character"
stream for any character class other than a base-char. How do I do this? :-)
Thanks!
Jeff M.
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-***@lispworks.com
http://www.lispworks.com/support/lisp-hug.html