ezHtml.ml1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28(**************************************************************************) (* *) (* Copyright 2020 OCamlPro & Origin Labs *) (* *) (* All rights reserved. This file is distributed under the terms of the *) (* GNU Lesser General Public License version 2.1, with the special *) (* exception on linking described in the file LICENSE. *) (* *) (**************************************************************************) let buffer b s = let add = Printf.bprintf b in for i = 0 to String.length s - 1 do match s.[i] with | '&' -> add "&" | '<' -> add "<" | '>' -> add ">" | '\'' -> add "'" | '\"' -> add """ | '@' -> add "@" | c -> Buffer.add_char b c done let string s = let b = Buffer.create (String.length s + 11) in buffer b s; Buffer.contents b