aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/file.erl
diff options
context:
space:
mode:
authorPatrik Nyblom <[email protected]>2010-11-08 17:25:01 +0100
committerPatrik Nyblom <[email protected]>2010-11-30 16:32:10 +0100
commit4161de166d46b6c9c25d5ac813c94a025c7a029d (patch)
treec3a7103b67bfdc0903ca700856a47ac7c9aaa84d /lib/kernel/src/file.erl
parentf16693691cbc8d6d4bff89c44cdc2c120ea637c3 (diff)
downloadotp-4161de166d46b6c9c25d5ac813c94a025c7a029d.tar.gz
otp-4161de166d46b6c9c25d5ac813c94a025c7a029d.tar.bz2
otp-4161de166d46b6c9c25d5ac813c94a025c7a029d.zip
Teach file to accept codepoints beyond 255.
Diffstat (limited to 'lib/kernel/src/file.erl')
-rw-r--r--lib/kernel/src/file.erl18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl
index 579b9132c6..08825c1c57 100644
--- a/lib/kernel/src/file.erl
+++ b/lib/kernel/src/file.erl
@@ -1037,20 +1037,22 @@ file_name(N) when is_binary(N) ->
N;
file_name(N) ->
try
- file_name_1(N)
+ file_name_1(N,file:native_name_encoding())
catch Reason ->
{error, Reason}
end.
-file_name_1([C|T]) when is_integer(C), C > 0, C =< 255 ->
- [C|file_name_1(T)];
-file_name_1([H|T]) ->
- file_name_1(H) ++ file_name_1(T);
-file_name_1([]) ->
+file_name_1([C|T],latin1) when is_integer(C), C < 256->
+ [C|file_name_1(T,latin1)];
+file_name_1([C|T],utf8) when is_integer(C) ->
+ [C|file_name_1(T,utf8)];
+file_name_1([H|T],E) ->
+ file_name_1(H,E) ++ file_name_1(T,E);
+file_name_1([],_) ->
[];
-file_name_1(N) when is_atom(N) ->
+file_name_1(N,_) when is_atom(N) ->
atom_to_list(N);
-file_name_1(_) ->
+file_name_1(_,_) ->
throw(badarg).
make_binary(Bin) when is_binary(Bin) ->