I'd like to create an HTML file from a String
, such as "abcdéèçàdefghijk"
. I tried different methods with no success. For example,
s = OpenWrite["test1.html", CharacterEncoding -> "ASCII"];
WriteString[s, "abcdéèçàdefghijk"]
Close[s]
returns a file with
abcde'e`c,a`defghijk
I managed to achieve my goal by specifying the encoding in the html file (<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
together with s = OpenWrite["test1.html", CharacterEncoding -> "UTF8"]
) but I am curious how this could be done from MMA encoding features.
OpenWrite["test1.html", CharacterEncoding -> "UTF8"]
? $\endgroup$<meta ...
in the html file. $\endgroup$charset
option. It does seem like a proper way of doing it. $\endgroup$ExportString[Cell[TextData["abcdéèçàdefghijk"],"Text"],"HTML","FullDocument"->False]
I adapted this from here. The solution uses standard HTML entities instead of unicode characters. That makes the exported code self-contained. $\endgroup$