IIUC when `read-char` reads from a port it assumes the port uses UTF-8 
encoding. [1] 

(My Racketuition suggests there might be a parameter called 
`current-port-encoding` that controls what encoding is applied to the port, but 
apparently not.)

So instead, one must convert the port explicitly. OK, this seems to work:

(open-input-string (bytes->string/latin-1 (port->bytes port)))

The problem is that I'm reading all the bytes first, which defeats the 
port-ishness of the operation.

But if I try the promising-sounding `reencode-input-port`:

(reencode-input-port port "latin-1")

This doesn't work, because it relies on `bytes-open-converter`, which 
apparently doesn't know about `latin-1` encoding (a teeny bit surprising since 
other racket/base functions deal with this encoding)

Hence the question: is there a smarter way to read characters from a `latin-1` 
encoded port?


[1] http://docs.racket-lang.org/reference/encodings.html?q=encoding 
<http://docs.racket-lang.org/reference/encodings.html?q=encoding>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to