Convert %char back into real chars

Results 1 to 2 of 2

Thread: Convert %char back into real chars

  1. #1
    Roger P. Guest

    Default Convert %char back into real chars

    Dear all<BR><BR>I pass some parameters to another page. There I save the whole query string of the URL in a SQL table.<BR><BR>When I use this string to build a link on my page all the percent characters (%20, %27) will be converted automatically. I don&#039t have anything to do with it. But I also want to show these strings on my page and there the convertion does not happen!<BR><BR>I could use the replace function but another solution would be better... <BR><BR>Thanks for your help<BR>Roger

  2. #2
    Join Date
    Dec 1969

    Default Server.URLDecode would be nice...

    ...but we don&#039t have it.<BR><BR>Fortunately, there is a sneaky trick that works:<BR><BR>******* yourPage.asp **********<BR><BR>&#060;SCRIPT Language=JavaScript RunAt=Server&#062;<BR>function decode( txt )<BR>{<BR>&nbsp;&nbsp;&nbsp; return unescape( txt );<BR>}<BR>&#060;/SCRIPT&#062;<BR><BR>&#060;%<BR>demo = "Does%20this%20work%3F%20%20It%20does%21!"<BR>Resp onse.Write decode(demo) & "&#060;P&#062;" & vbNewLine<BR>%&#062;<BR><BR>*******************<BR ><BR>JavaScript has a function (unescape) *built in* that does this for you (yes, it also has escape built in, to do the encoding in the first place). Yes, you *can* write a function in JavaScript and then call it from VBScript.<BR><BR>This is not the fastest thing in the world (cross language scripting), so use it sparingly.<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