Best HTML encoder for Delphi?

It looks like my data gets corrupted when using HTTPapp.HTMLEncode (string): String;

HTMLEncode( 'Jo&hn D<oe' ); // returns 'Jo&am'

This is incorrect and distorts my data. Anyone have suggestions for VCL components that work better? Besides wasting time coding all cases

http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references

Update

Understanding more about HTML, I found that there was no need to encode the other characters mentioned in my link. You will only need to know the four reserved HTML characters:

&,<,>,"

The problem with the VCL function HTTPApp.HTMLEncode () is related to the buffer size and the new Delphi 2009/2010 specifications for standard Unicode strings by default, this can be fixed so that @mason says below, or it can be fixed by calling WideFormatBuf () instead currently used FormatBuf ().

+5
source share
3 answers

Replacing the characters <,>, &, and "characters in a string is trivial. Thus, you can easily write your own procedure for this. (And if your HTML page is UTF-8, there is absolutely no reason to encode any other characters. such as U + 222B (integral sign).)

Delphi RTL, HTTPUtil.HTMLEscape , HTTPApp.HTMLEncode.

, SO.

+5

, Delphi 2009 2010 . , HTMLEncode Unicode. FormatBuf.

HTMLEncode , , . , . FormatBuf, 5 . - . ( ), .

, QC, .

+3

: (') &apos; - , &apos; HTML

For details, see. " The Curse " and " the XHTML and ' " &apos;

(Both mentioned Delphi units do not convert single quotes).

+3
source

All Articles