[plt-scheme] Encodings in PLT Scheme

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Jun 25 17:41:29 EDT 2007

At Mon, 25 Jun 2007 23:26:04 +0200, "Jean-Pierre Lozi" wrote:
> How do encodings in PLT-scheme work? I have a list, stored in a file.
> This list contains strings, with accentuated characters. It appears
> that, whether I use drscheme in UTF-8 or ISO-8859-15 (result of
> (locale-source-encoding)), using the "read" function only works when
> the file is encoded with UTF-8. Otherwise, I get question marks
> instead of accentuated characters.
> 
> Moreover, when reading a file not encoded in UTF-8, I have to use
> read-bytes-line and bytes->string/latin-1, otherwise, I get question
> marks instead of accentuated characters.
> 
> I don't really understand why.
> 
> Any ideas?

`open-input-file' and other such functions don't use the current
locale's encoding. But you can use `reencode-input-port' from `(lib
"port.ss")':

 (reencode-input-port in-port (locale-string-encoding)) ; locale's

or

 (reencode-input-port in-port "ISO-8859-1") ; Latin-1



Matthew



Posted on the users mailing list.