Printer for XML.
The encoder maps strings to HTML and must encode the unsafe characters
'&' and the control characters 0-8, 11-12, 14-31, 127
to HTML entities.
encode_unsafe is the default for
pretty_print below. Other implementations are provided by the module
Netencoding in the
let encode = Netencoding.Html.encode ~in_enc:`Enc_iso88591 ~out_enc:`Enc_usascii (),
Where national characters are replaced by HTML entities.
The user is of course free to write her own implementation.
In addition, encode
"@" in the hope that this will fool
simple minded email address harvesters.
encoding is the name of the character encoding, e.g.
Utf8 normalizer and encoder for HTML.
Given a module
Htmlprinter produced by one of the functors in [root:Xml_print], this modules is used as following:
let encode x = fst (Utf8.normalize_html x) in Htmlprinter.print ~encode document
normalize str take a possibly invalid utf-8 string
and return a valid utf-8 string
where invalid bytes have been replaced by
the replacement character
The returned boolean is true if invalid bytes were found