I’ve got a report that’s supposed to take a grid control and produce HTML output. One of the columns in the grid can display any of a number of values, or <Any>. When this gets output to HTML, of course, it ends up blank.
I could probably write up some routine to use StringReplace to turn that into <Any> so it would display this particular case correctly, but I figure there’s probably one in the RTL somewhere that’s already been tested and does it right. Anyone know where I could find it?
I am 99 % sure that such a function does not exist in the RTL (as of Delphi 2009). Of course – however – it is trivial to write such a function.
Update
HTTPUtil.HTMLEscape is what you are looking for:
I don’t dare to publish the code here (copyright violation, probably), but the routine is very simple. It encodes “<“, “>”, “&”, and “”” to
<,>,&, and". It also replaces characters #92, #160..#255 to decimal codes, e.g.\.This latter step is unnecessary if the file is UTF-8, and also illogical, because higher special characters, such as ∮ are left as they are, while lower special characters, such as ×, are encoded.
Update 2
In response to the answer by Stijn Sanders, I made a simple performance test.
The output is