View Full Version : request.form encoding

12-13-2004, 12:37 PM
when i just do Response.Write Reqest.Form it enters spaces as + and semicolons as %3B and ' and " as %27 and %22 etc.. is there any way to quickly get everything back to ; ' " etc (i tried server.urlencode() and server.htmlencode() but neither do it

i suppose i could probably do a for each loop and just write it to a string (eg Request.Form("field1") comes out as "hello everyone" but in request.form it comes out as field1=hello+everyone so maby

Function URLDecode(strRawFormData)
For Each frmField in strRawFormData
URLDecode = URLDecode & frmField & "=" & strRawFormData(frmField) & "&"
URLDecode = Left(URLDecode, Len(URLDecode)-1)
End Function

Response.Write "Raw Request.Form = " & Request.Form & "<br>"
Response.Write "New Request.Form = " & URLDecode(Request.Form)

'Returns a result like this:
'Raw Request.Form = field1=hello+everyone%2C&field2=how+are+you+doing+today%3F
'New Request.Form = field1=hello everyone,&field2=how are you doing today?
but i dont know if its the best way of doing this (obvisouly a built in function would be better than a loop)

12-13-2004, 02:07 PM
When you output the Request.Form collection, it displays the URL-encoded form data but if you retrieve each item in the collection, the data is automatically decoded.

'Raw Request.Form = field1=hello+everyone%2C&field2=how+are+you+doing+today%3F

response.write(request.form("field1")) 'outputs hello everyone,
response.write(request.form("field2")) 'outputs how are you doing today?

12-13-2004, 04:39 PM
pfft glen ur sposed to be useful (thats why i thank you every time i post ;))

i already knew that the Request.Form(..) decoded the element of Request.Form .. thats why i put that code there.. but i wondered if there was a built in function rather than the one i made that does the same thing (since there is one for the other way with server.urlencode)

so some sort of server.urlDEcode() would be useful but that isnt there so if something else did it itd be great.. the function i wrote while writing this post earlier was fine but i didnt know if there was a better way

12-14-2004, 02:30 AM
There is Server.URLDecode function method in ASP.NET but not in classic ASP.

12-14-2004, 01:27 PM
okidoki, thanks m8.. ill just use that function then :thumbsup:

i wasnt sure if it actually was the reverse of urlencode or not btw :p

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum