diff --git a/examples/file_server/priv/中文.html b/examples/file_server/priv/中文.html new file mode 100644 index 00000000..d3711818 --- /dev/null +++ b/examples/file_server/priv/中文.html @@ -0,0 +1,8 @@ + + + + + + 你好! + + diff --git a/examples/file_server/priv/中文/中文.html b/examples/file_server/priv/中文/中文.html new file mode 100644 index 00000000..d3711818 --- /dev/null +++ b/examples/file_server/priv/中文/中文.html @@ -0,0 +1,8 @@ + + + + + + 你好! + + diff --git a/examples/file_server/src/directory_h.erl b/examples/file_server/src/directory_h.erl index 66e1466b..16086246 100644 --- a/examples/file_server/src/directory_h.erl +++ b/examples/file_server/src/directory_h.erl @@ -32,12 +32,12 @@ content_types_provided(Req, State) -> ], Req, State}. list_json(Req, {Path, Fs}) -> - Files = [ <<(list_to_binary(F))/binary>> || F <- Fs ], + Files = [ <<(unicode_to_iolist(F))/binary>> || F <- Fs ], {jsx:encode(Files), Req, Path}. list_html(Req, {Path, Fs}) -> - Body = [[ links(Path, F) || F <- [".."|Fs] ]], - HTML = [<<"Index", + Body = [[ links(Path, unicode_to_iolist(F)) || F <- [".."|Fs] ]], + HTML = [<<"Index", "">>, Body, <<"\n">>], {HTML, Req, Path}. @@ -51,3 +51,7 @@ links(<<>>, File) -> ["", File, "
\n"]; links(Prefix, File) -> ["", File, "
\n"]. + + +unicode_to_iolist(UniString) -> + binary_to_list(unicode:characters_to_binary(UniString)).