Lisp HUG Maillist Archive

write-char and external format

I thought that write-char would do the right thing based on the 
external format of the stream. But when I try the test below, I don't 
get the same file I get from saving this string in the editor with the 
same external format. Bug or misconception?

The original string is:

'©«¡®£§¼½¾¿ ÀÉÌÓÙÝ àéìóùý āŹźŻżŽž ∧∨'

The result I get from the function below is:

'©«¡®£§¼½¾¿ ÀÉÌÓÙÝ àéìóùý yz{|}~ '('


(defun tst ()
   (let ((chars '(#\U+0027 ;single quote
                  #\U+00A9 #\U+00AB #\U+00A1 #\U+00AE #\U+00A3 #\U+00A7 
#\U+00BC #\U+00BD #\U+00BE #\U+00BF #\U+0020
                  #\U+00C0 #\U+00C9 #\U+00CC #\U+00D3 #\U+00D9 #\U+00DD 
#\U+0020 #\U+00E0 #\U+00E9 #\U+00EC #\U+00F3
                  #\U+00F9 #\U+00FD #\U+0020 #\U+0101 #\U+0179 #\U+017A 
#\U+017B #\U+017C #\U+017D #\U+017E #\U+0020
                  #\U+2227 #\U+2228
                  #\U+0027)))
     (with-open-file  (ff "~/utf8.txt" :direction :output 
:external-format '(:utf-8 :eol-style :lf) :if-exists :supersede)
       (loop for ch in chars do (write-char ch ff)))))




John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


Re: write-char and external format

Unable to parse email body. Email id is 3553

Updated at: 2020-12-10 08:53 UTC