G
Guest
In working with System.Web.HttpUtility class, I've come across some
inconsistencies in encoding and decoding. If I start with the following code:
string s = @"& " ' < > ® ™ © é";
s = System.Web.HttpUtility.HtmlDecode(s);
s = System.Web.HttpUtility.HtmlEncode(s);
The value of the string after the call to HtmlDecode is:
& \" ' < > ® ™ © é
This indicates that it doesn't correctly decode the (&apos to be a single
quote ('), otherwise, it decodes all characters correctly. Further, the
value of the string after the call to HtmlEncode is:
& " ' < > ® ™ © é
This indicates that it doesn't re-encode all the characters correctly
(notice the &apos double encoding due to the initial decoding error, as well
as the inability to encode the TM symbol at all).
Does anyone have any insight into why this is happening?
inconsistencies in encoding and decoding. If I start with the following code:
string s = @"& " ' < > ® ™ © é";
s = System.Web.HttpUtility.HtmlDecode(s);
s = System.Web.HttpUtility.HtmlEncode(s);
The value of the string after the call to HtmlDecode is:
& \" ' < > ® ™ © é
This indicates that it doesn't correctly decode the (&apos to be a single
quote ('), otherwise, it decodes all characters correctly. Further, the
value of the string after the call to HtmlEncode is:
& " ' < > ® ™ © é
This indicates that it doesn't re-encode all the characters correctly
(notice the &apos double encoding due to the initial decoding error, as well
as the inability to encode the TM symbol at all).
Does anyone have any insight into why this is happening?