Should the output of HttpUtility.HtmlDecode() is the same as brows

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there!,

I've found that HttpUtility.HtmlDecode() will not decode to space if the
input text is something like "<b>SKY CAPTAIN & THE WORLD OF&nbsp;</b>". The
output is the same as the input. But output on browser is correct. Should
the output of HttpUtility.HtmlDecode() is the same as browser? Because I've
to rendor html to text as a browser does. So if HttpUtility.HtmlDecode() does
not do the same way as browser does, how should I do my job with FCL?

Thanks,
Thana N.
 
That's because the string wasn't properly HTML-encoded in the first place.
The ampersand ("&") in the middle needs to be replaced by the "&amp;" known
entity. i.e.:

<b>SKY CAPTAIN &amp; THE WORLD OF&nbsp;</b>

Once this is done, the string can be HTML-decoded properly to "<b>SKY
CAPTAIN & THE WORLD OF </b>".

BTW, the reason you were seeing the string you expected in the browser was
that the browser was being permissive of the invalid HTML.

HTH,
Nicole
 
Back
Top