'ASP URLDecode - Incorrect Conversion
I have a website where google pics up some links on my site and sends throught the following URL
http://www.globalpropertyonline.net/test.asp?town=gand%EDa
I have one of the URLDecode Functions I found on the net to Decode the %ED
However, this seems not to be working the correct way.
The %ED should be this : í
So when I Decode it the word should be gandía
But instead I get the following word : gand�a
On the page where google gets the link, it is displayed correctly as gandía but it prompts me in webmaster tools that the following link has a error 500 and this is because when I try to take this name and sends it to the MYSQL query it crash with error 500 but if I would have had gandía then it worked !
So, my main problem is that I am getting the %ED sent as URLEncode as it seems and I want to Decode it before I send it to my database query.
In my ASP Page I am using UTF-8 Encodeing as follows.
<%@ CodePage=65001 Language="VBScript"%>
<%
Response.CodePage = 65001
Response.CharSet = "utf-8"
This is the Code I am using to Decode it but instead if getting the gandía I get this : gand�a
any help will be much apreciated
<%@ CodePage=65001 Language="VBScript"%>
<%
Response.CodePage = 65001
Response.CharSet = "utf-8"
MyTown = Request("town")
response.write URLDecode(MyTown)
Function URLDecode(str)
str = Replace(str, "+", " ")
For i = 1 To Len(str)
sT = Mid(str, i, 1)
If sT = "%" Then
If i+2 < Len(str) Then
sR = sR & _
Chr(CLng("&H" & Mid(str, i+1, 2)))
i = i+2
End If
Else
sR = sR & sT
End If
Next
URLDecode = sR
End Function
%>
Solution 1:[1]
It looks like you have not defined the page as UTF-8 client-side. You can this by adding this inside <head></head>:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sander_P |
