Decode HTMLEncoded string

Results 1 to 2 of 2

Thread: Decode HTMLEncoded string

  1. #1
    Join Date
    Dec 1969

    Default Decode HTMLEncoded string

    Hi,<BR><BR>There is Server.HTMLEncode to encode the special HTML chars like &#060; or & into &amp;lt; and &amp;amp;. <BR><BR>My task is vice versa to decode an encoded string. And it wouldn&#039t be a problem if the encoded string could have only &#060;, &amp;quot; or &amp;amp; kind of codes. I would just write a function to remap these back into the chars. But encoded string can have &amp;#241, &amp;#8417, etc. So, I would have a hell of a function to write :(<BR><BR>Does anybody know how to decode in some less complicated way?<BR><BR>Thank you in advance,<BR>Serge Baranovsky<BR>

  2. #2
    Join Date
    Dec 1969

    Default *WHY* are you doing it???

    Why would you ever put an HTML encoded string anyplace but out to the browser? And once it is there, how do you pull it back?<BR><BR>ANYWAY...<BR><BR>You *can* do it, if you really need to.<BR><BR>&#060;%<BR>start = 1<BR>Do While True<BR>&nbsp; &nbsp; &#039 find start of a numerically specified character<BR>&nbsp; &nbsp; start = InStr( start, theString, "&#" ) <BR>&nbsp; &nbsp; If start = 0 Then Exit Do<BR>&nbsp; &nbsp; &#039 and end of that character<BR>&nbsp; &nbsp; semi = InStr( start, theString, ";" )<BR>&nbsp; &nbsp; val = Mid( theString, start+2, semi-start-2 )<BR>&nbsp; &nbsp; If val &#062; 255 Then ch = ChrW(val) Else ch = Chr(val)<BR>&nbsp; &nbsp; theString = Replace( theString, "&#" & val & ";", ch )<BR>Loop<BR>%&#062;<BR><BR>I think that works. Untested. I think the boundary between Chr and ChrW is 255/256. I know you can&#039t use ChrW unless the locale/codepage in use allows it.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts