Octav Popescu | 5 Jun 23:43

Text files in MCL 5.2

MCL 5.2 seems to have a problem with text files. It assumes the input 
file is encoded in MacRoman and converts it to Unicode strings on 
reading, but it doesn't do a reverse conversion on writing. And then it 
just writes the lower bytes of the unicode codes. So for instance if you do:

(with-open-file (in "Home:In.lisp")
    (with-open-file (out "Home:Out.lisp" :direction :output :if-exists 
:supersede)
      (princ (read-line in) out)))

And if you have a line with foreign language characters in "In.lisp", 
you end up with different characters in "Out.lisp". So if you read it 
again, you get a different text than the first time. Does anybody have a 
solution for this problem? I found a workaround by calling 
ccl::convert-string-to-mac-encodings on the string before writing it, 
but I'm hoping for a better integrated solution, which I can save as a 
patch.

Thanks,
Octav
_______________________________________________
info-mcl mailing list
info-mcl@...
http://clozure.com/mailman/listinfo/info-mcl

p2.edoc | 7 Jun 08:39

Re: Text files in MCL 5.2

At 5:47 PM -0400 08/06/05, Octav Popescu wrote:
>MCL 5.2 seems to have a problem with text files. It assumes the input
>file is encoded in MacRoman and converts it to Unicode strings on
>reading, but it doesn't do a reverse conversion on writing. And then it
>just writes the lower bytes of the unicode codes.

In the MCL 5.2 save file dialog is a new Format option for external-format
[MCL 5.1 Format]
[Unicode (UTF8)]
[Unicode (UTF16)]
[Unix line endings]

If a file is saved in [MCL 5.1 Format] or [Unix 
line endings] by 5.2 is should be read as 
original under MCL pre 5.2.

MCL 5.2 file saved as [Unicode (UTF8)],  under 
5.1 we see the BOM (Ôªø) file prefix.
         ditto         [Unicode (UTF16)], under 5.1 it cannot be read

the external file's format is found using 
utf-something-p (which assumes nothing, rather 
investigates the file contents and 
FSCataloginfo.FinderInfo.filetype).

for internal state, file-external-format looks 
for (view-get window :external-format).

if we save as [MCL 5.1 Format] ccl::view-alist has :EXTERNAL-FORMAT nil.

(Continue reading)


Gmane