aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/erl_tar.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2014-04-09 12:42:32 +0200
committerBjörn Gustavsson <[email protected]>2014-05-08 14:26:27 +0200
commit61138cb31e1f6ad44d3ca54e668de9d2d4adb2ec (patch)
treeded5ff5de1c9f386601a7e16ac922ab279650fe4 /lib/stdlib/src/erl_tar.erl
parent07b8f441ca711f9812fad9e9115bab3c3aa92f79 (diff)
downloadotp-61138cb31e1f6ad44d3ca54e668de9d2d4adb2ec.tar.gz
otp-61138cb31e1f6ad44d3ca54e668de9d2d4adb2ec.tar.bz2
otp-61138cb31e1f6ad44d3ca54e668de9d2d4adb2ec.zip
Support path names with characters outside the US ASCII range
Diffstat (limited to 'lib/stdlib/src/erl_tar.erl')
-rw-r--r--lib/stdlib/src/erl_tar.erl24
1 files changed, 22 insertions, 2 deletions
diff --git a/lib/stdlib/src/erl_tar.erl b/lib/stdlib/src/erl_tar.erl
index 40b48d7999..89b4ea6c04 100644
--- a/lib/stdlib/src/erl_tar.erl
+++ b/lib/stdlib/src/erl_tar.erl
@@ -381,7 +381,12 @@ to_octal(Int, Count, Result) ->
to_octal(Int div 8, Count-1, [Int rem 8 + $0|Result]).
to_string(Str0, Count) ->
- Str = list_to_binary(Str0),
+ Str = case file:native_name_encoding() of
+ utf8 ->
+ unicode:characters_to_binary(Str0);
+ latin1 ->
+ list_to_binary(Str0)
+ end,
case byte_size(Str) of
Size when Size < Count ->
[Str|zeroes(Count-Size)];
@@ -608,7 +613,22 @@ typeflag(Bin) ->
%% Get the name of the file from the prefix and name fields of the
%% tar header.
-get_name(Bin) ->
+get_name(Bin0) ->
+ List0 = get_name_raw(Bin0),
+ case file:native_name_encoding() of
+ utf8 ->
+ Bin = list_to_binary(List0),
+ case unicode:characters_to_list(Bin) of
+ {error,_,_} ->
+ List0;
+ List when is_list(List) ->
+ List
+ end;
+ latin1 ->
+ List0
+ end.
+
+get_name_raw(Bin) ->
Name = from_string(Bin, ?th_name, ?th_name_len),
case binary_to_list(Bin, ?th_prefix+1, ?th_prefix+1) of
[0] ->