From 567115dab453dd05b74b28c5130582c14fe67bc5 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Tue, 18 Dec 2012 16:19:24 +0100 Subject: [test_server] Add Unicode support to module listing Code written by Siri Hansen. --- lib/test_server/src/erl2html2.erl | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'lib/test_server/src/erl2html2.erl') diff --git a/lib/test_server/src/erl2html2.erl b/lib/test_server/src/erl2html2.erl index 9c459c05d4..1729257809 100644 --- a/lib/test_server/src/erl2html2.erl +++ b/lib/test_server/src/erl2html2.erl @@ -34,11 +34,17 @@ convert(File, Dest) -> %% %% FIXME: The colours should *really* be set with %% stylesheets... + Encoding = encoding(File), Header = ["\n" "\n" "\n" - "", File, "\n\n" + "\n" + "\n" + "", File, "\n" + "\n\n" "\n"], convert(File, Dest, Header). @@ -55,12 +61,12 @@ convert(File, Dest, Header) -> case file:open(Dest,[write,raw]) of {ok,DFd} -> file:write(DFd,[Header,"
\n"]),
-			    Lines = build_html(SFd,DFd,Functions),
+			    _Lines = build_html(SFd,DFd,Functions),
 			    file:write(DFd,["
\n",footer(), "\n\n"]), %% {_, Time2} = statistics(runtime), %% io:format("Converted ~p lines in ~.2f Seconds.~n", - %% [Lines, Time2/1000]), + %% [_Lines, Time2/1000]), file:close(SFd), file:close(DFd), ok; @@ -180,3 +186,20 @@ possibly_enhance(Str,false) -> %%% End of the file footer() -> "". + +%%%----------------------------------------------------------------- +%%% Read encoding from source file +encoding(File) -> + Encoding = + case epp:read_encoding(File) of + none -> + epp:default_encoding(); + E -> + E + end, + html_encoding(Encoding). + +html_encoding(latin1) -> + "iso-8859-1"; +html_encoding(utf8) -> + "utf-8". -- cgit v1.2.3