aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/escript.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stdlib/src/escript.erl')
-rw-r--r--lib/stdlib/src/escript.erl8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/stdlib/src/escript.erl b/lib/stdlib/src/escript.erl
index 32742e419b..fea718541d 100644
--- a/lib/stdlib/src/escript.erl
+++ b/lib/stdlib/src/escript.erl
@@ -602,9 +602,15 @@ parse_beam(S, File, HeaderSz, CheckOnly) ->
parse_source(S, File, Fd, StartLine, HeaderSz, CheckOnly) ->
{PreDefMacros, Module} = pre_def_macros(File),
IncludePath = [],
- {ok, _} = file:position(Fd, {bof, HeaderSz}),
+ %% Read the encoding on the second line, if there is any:
+ {ok, _} = file:position(Fd, 0),
+ _ = io:get_line(Fd, ''),
+ Encoding = epp:set_encoding(Fd),
+ {ok, _} = file:position(Fd, HeaderSz),
case epp:open(File, Fd, StartLine, IncludePath, PreDefMacros) of
{ok, Epp} ->
+ _ = [io:setopts(Fd, [{encoding,Encoding}]) ||
+ Encoding =/= none],
{ok, FileForm} = epp:parse_erl_form(Epp),
OptModRes = epp:parse_erl_form(Epp),
S2 = S#state{source = text, module = Module},