aboutsummaryrefslogtreecommitdiffstats
path: root/lib/test_server/src/ts_lib.erl
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2013-01-18 17:38:11 +0100
committerSiri Hansen <[email protected]>2013-01-25 15:56:00 +0100
commit9c262fece1241bd006cd78ce84b63e4924c55325 (patch)
tree5bfbbbba6ca5128682790dc437f3020f00cf4d40 /lib/test_server/src/ts_lib.erl
parentc463aaf0355d3a958df2335d13dc88aafb667f40 (diff)
downloadotp-9c262fece1241bd006cd78ce84b63e4924c55325.tar.gz
otp-9c262fece1241bd006cd78ce84b63e4924c55325.tar.bz2
otp-9c262fece1241bd006cd78ce84b63e4924c55325.zip
[ts] Use unicode:characters_to_list/2 instead of binary_to_list/1
When reading text files with file:read_file/1, assume that the file has the default encding (epp:default_encoding()) and covert the binary to string by unicode:characters_to_list(Bin,DefaultEncoding) instead of binary_to_list(Bin) as before.
Diffstat (limited to 'lib/test_server/src/ts_lib.erl')
-rw-r--r--lib/test_server/src/ts_lib.erl15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/test_server/src/ts_lib.erl b/lib/test_server/src/ts_lib.erl
index c0200ab67c..a00f607fc1 100644
--- a/lib/test_server/src/ts_lib.erl
+++ b/lib/test_server/src/ts_lib.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1997-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
@@ -29,7 +29,8 @@
specs/1, suites/2,
subst_file/3, subst/2, print_data/1,
make_non_erlang/2,
- maybe_atom_to_list/1, progress/4
+ maybe_atom_to_list/1, progress/4,
+ b2s/1
]).
error(Reason) ->
@@ -155,7 +156,7 @@ suite_order(_) -> 200.
subst_file(In, Out, Vars) ->
case file:read_file(In) of
{ok, Bin} ->
- Subst = subst(binary_to_list(Bin), Vars, []),
+ Subst = subst(b2s(Bin), Vars, []),
case file:write_file(Out, Subst) of
ok ->
ok;
@@ -334,3 +335,11 @@ make_non_erlang_do(DataDir, Variables) ->
after
timer:sleep(100) %% maybe unnecessary now when we don't do set_cwd anymore
end.
+
+b2s(Bin) ->
+ unicode:characters_to_list(Bin,default_encoding()).
+
+default_encoding() ->
+ try epp:default_encoding()
+ catch error:undef -> latin1
+ end.