aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2013-02-05 11:33:13 +0100
committerSiri Hansen <[email protected]>2013-02-21 11:03:35 +0100
commita2d08a9ce78f18ce37086f3c65f743cfae4f7f1b (patch)
tree25bd115e31e0c512acd161f164595788d0902339 /lib
parentdc6c6f1d556e4e51ce8d7d1f3f1b5062fdd6e144 (diff)
downloadotp-a2d08a9ce78f18ce37086f3c65f743cfae4f7f1b.tar.gz
otp-a2d08a9ce78f18ce37086f3c65f743cfae4f7f1b.tar.bz2
otp-a2d08a9ce78f18ce37086f3c65f743cfae4f7f1b.zip
[reltool] Honour encoding in reltool_utils:prim_consult
This function is similar to file:consult, except it also operates on a binary (e.g. read from an archive). The function now takes magic encoding comment into account.
Diffstat (limited to 'lib')
-rw-r--r--lib/reltool/src/reltool_utils.erl12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/reltool/src/reltool_utils.erl b/lib/reltool/src/reltool_utils.erl
index 6149d6ef06..90831ecac7 100644
--- a/lib/reltool/src/reltool_utils.erl
+++ b/lib/reltool/src/reltool_utils.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2009-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2009-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -106,7 +106,7 @@ normalize_dir([], Path) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
prim_consult(Bin) when is_binary(Bin) ->
- case erl_scan:string(binary_to_list(Bin)) of
+ case erl_scan:string(unicode:characters_to_list(Bin,encoding(Bin))) of
{ok, Tokens, _EndLine} ->
prim_parse(Tokens, []);
{error, {_ErrorLine, Module, Reason}, _EndLine} ->
@@ -120,6 +120,14 @@ prim_consult(FullName) when is_list(FullName) ->
{error, file:format_error(enoent)}
end.
+encoding(Bin) when is_binary(Bin) ->
+ case epp:read_encoding_from_binary(Bin) of
+ none ->
+ epp:default_encoding();
+ E ->
+ E
+ end.
+
prim_parse(Tokens, Acc) ->
case lists:splitwith(fun(T) -> element(1,T) =/= dot end, Tokens) of
{[], []} ->