Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASCII stream decoding error in cl-html-parse

I get an ASCII stream decoding error when I run this:

(with-open-file (stream file)
    (net.html.parser:parse-html stream))

I'm using SBCL 1.0.58 and cl-html-parse 20101006 (using quicklisp).

I get the error fairly frequently trying to parse pages I download with curl (in a regular shell). Most are UTF-8.

Should I somehow be specifying an encoding for the file, and how would I do that?

like image 614
banjomonster Avatar asked May 23 '26 08:05

banjomonster


1 Answers

After reading a bit more on with-open-file, I found I can make this work by specifying :external-format.

(with-open-file (stream file
                        :if-does-not-exist nil
                        :external-format :UTF-8)
    (net.html.parser:parse-html stream))

Still trying to figure out writing (I get a similar error), but I think I'm looking in the right place now.

like image 88
banjomonster Avatar answered May 26 '26 04:05

banjomonster