Hi,
I am stuck in the unfortunate situation of having to pass a string to another page through the URL. This is unfortunate as characters like "&" will cut off the end of the string, but it is even worse because "'" breaks the application. The first solution that popped into mind last Friday was to convert the offending characters into non-offending strings. I have a JavaScript program that turns:
"Bob's Trucks & Hardware"
into
"Bob_SQUOTE_s Trucks _AMPERSAND_ Hardware" to put in the URL.
I'm trying to write a function on the ASP page to "decode" this, but it is returning
"Bob's Trucks &Hardware" (notice the missing space).
This is important because I have to match the string against a database to see if it is contained or not, so it is a fairly significant problem. I am certainly open to other approaches to the problem, and any help is greatly appreciated.
Thanks guys!
-Nm
The function I am using is:
Function UnUrlSAFE (str)
While str <> ""
delimeter = instr(str,"_SQUOTE_"
if delimeter = 0 then
if newStr <> "" then
newStr = newStr & "'" & str
else
newStr = str
end if
str = ""
elseif newStr <> "" then
newStr = newStr & "'" & mid(str,1,delimeter-1)
str = trim(mid(str,delimeter+8))
else
newStr = mid(str,1,delimeter-1)
str = trim(mid(str,delimeter+8))
end if
WEND
str = newStr
newStr = ""
While str <> ""
delimeter = instr(str,"_AMPERSAND_"
if delimeter = 0 then
if newStr <> "" then
newStr = newStr & "&" & str
else
newStr = str
end if
str = ""
elseif newStr <> "" then
newStr = newStr & "&" & mid(str,1,delimeter-1)
str = trim(mid(str,delimeter+11))
else
newStr = mid(str,1,delimeter-1)
str = trim(mid(str,delimeter+11))
end if
WEND
UnUrlSAFE = newStr
End Function
I am stuck in the unfortunate situation of having to pass a string to another page through the URL. This is unfortunate as characters like "&" will cut off the end of the string, but it is even worse because "'" breaks the application. The first solution that popped into mind last Friday was to convert the offending characters into non-offending strings. I have a JavaScript program that turns:
"Bob's Trucks & Hardware"
into
"Bob_SQUOTE_s Trucks _AMPERSAND_ Hardware" to put in the URL.
I'm trying to write a function on the ASP page to "decode" this, but it is returning
"Bob's Trucks &Hardware" (notice the missing space).
This is important because I have to match the string against a database to see if it is contained or not, so it is a fairly significant problem. I am certainly open to other approaches to the problem, and any help is greatly appreciated.
Thanks guys!
-Nm
The function I am using is:
Function UnUrlSAFE (str)
While str <> ""
delimeter = instr(str,"_SQUOTE_"
if delimeter = 0 then
if newStr <> "" then
newStr = newStr & "'" & str
else
newStr = str
end if
str = ""
elseif newStr <> "" then
newStr = newStr & "'" & mid(str,1,delimeter-1)
str = trim(mid(str,delimeter+8))
else
newStr = mid(str,1,delimeter-1)
str = trim(mid(str,delimeter+8))
end if
WEND
str = newStr
newStr = ""
While str <> ""
delimeter = instr(str,"_AMPERSAND_"
if delimeter = 0 then
if newStr <> "" then
newStr = newStr & "&" & str
else
newStr = str
end if
str = ""
elseif newStr <> "" then
newStr = newStr & "&" & mid(str,1,delimeter-1)
str = trim(mid(str,delimeter+11))
else
newStr = mid(str,1,delimeter-1)
str = trim(mid(str,delimeter+11))
end if
WEND
UnUrlSAFE = newStr
End Function