[erlang-questions] file:consult {error, {1, file_io_server, invalid_unicode}} with pre-r17 files in r17

Russell Brown <>
Thu Apr 23 16:14:42 CEST 2015


Hi,
Top posting _and_ answering my own question, ban me now!

In case anyone else runs into the problem, and doesn’t think of a better way (there must be one!)

I accomplished reading files written from r16 using 

    io_lib:format("~p.", [Term]),

in r17 just by copying the code from `file:consult/1` but changing

    _ = epp:set_encoding(FD).

to

    _ = epp:set_encoding(FD, latin1).

Will just add it to some internal library module for robust consulting of files of unknown origin.

Cheers

Russell

On 23 Apr 2015, at 10:20, Russell Brown <> wrote:

> Hi,
> With the release of r17, certain files that were written in earlier versions of erlang are not `file:consult/1`-able in r17.
> 
> Here is a simple module that shows the issue: https://gist.github.com/russelldb/4f8fe205bd5a5a1cd136
> 
> If I change line 13 to
> 
> 	io_lib:format(“~w.", [Term]),
> 
> Everything works just fine. However, legacy files were written in r16 using
> 
> 	io_lib:format("~p.", [Term]),
> 
> And I’d like to be able to read them into erlang terms in r17, has someone already tackled this?
> 
> Many thanks in advance for your suggestions
> 
> Russell



More information about the erlang-questions mailing list