Replace and url.encode doesn't work for me...

Results 1 to 2 of 2

Thread: Replace and url.encode doesn't work for me...

  1. #1
    Jean-Hugues Ravel Guest

    Default Replace and url.encode doesn't work for me...

    Hello !<BR>I have a QueryString of this type: File2.asp?Alt=A%20text%20to%20display<BR>coming from a redirection asp file with the get method. Now, I want to get rid of %20 space characters and others. I&#039ve tried the replace method but somehow it refuses the replacement of % (VBScript compilation error 1033 : Unterminated string constant). I&#039ve also tried the url.encode(...) but it doesn&#039t work either.<BR><BR>Here is the real example:<BR><BR><BR>Have a look there. The source code is readable at:<BR><BR><BR>The picture.asp file can be found at:<BR><BR><BR>Thanks a lot for your help.<BR>P.S. : please write also directly to my email address (

  2. #2
    Join Date
    Dec 1969

    Default RE: Replace and url.encode doesn't work for me

    Hi I found the following function in a ASP book which <BR>decodes a encoded string. May be you can use this fumction.<BR>Good Luck.<BR><BR>===============<BR><BR>&#060;SCRIPT LANGUAGE=VBScript RUNAT=Server&#062;<BR>Function URLDecode(strToDecode)<BR> strIn = strToDecode<BR> strOut = ""<BR> intPos = Instr(strIn, "+") &#039look for + and replace with space<BR> Do While intPos<BR> strLeft = ""<BR> strRight = ""<BR> If intPos &#062; 1 Then strLeft = Left(strIn, intPos - 1)<BR> If intPos &#060; Len(strIn) Then strRight = Mid(strIn, intPos + 1)<BR> strIn = strLeft & " " & strRight<BR> intPos = Instr(strIn, "+") &#039and then look for next one<BR> intLoop = intLoop + 1<BR> Loop<BR> intPos = Instr(strIn, "%") &#039look for ASCII coded characters<BR> Do While intPos<BR> If intPos &#062; 1 Then strOut = strOut & Left(strIn, intPos - 1)<BR> strOut = strOut & Chr(CInt("&H" & Mid(strIn, intPos + 1, 2)))<BR> If intPos &#062; (Len(strIn) - 3) Then <BR> strIn = ""<BR> Else<BR> strIn = Mid(strIn, intPos + 3)<BR> End If<BR> intPos = Instr(strIn, "%") &#039and then look for next one<BR> Loop<BR> URLDecode = strOut & strIn<BR>End Function<BR>&#060;/SCRIPT&#062;

Posting Permissions

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