Question Decoding special characters with Request.QueryString.Item

tedweatherly

New member
Joined
Jun 25, 2009
Messages
1
Programming Experience
3-5
Hey folks I'm having a problem and I'd like your help. I'm trying to decode special characters in parameter values passed into a web page. Here's my script:

<%Response.charset="UTF-8"%>
<%@ Page Explicit="true" %>
<script language="VB" runat="Server">
</script>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<head>
<title></title>
</head>
<body>
<%Response.Write("Amélie")%><br/>
<%Response.Write(Request.QueryString.Item("fname"))%><br/>
<%Response.Write(Request("fname"))%>
</body>
</html>

Pretty simple right? So I go to:

http://[hostname]/[path]/test.aspx?fname=Am%E9lie

And I see this in the browser:

Amélie
Amlie
Amlie

Why does this simple script mess up on on the "é" character? %E9 does decode to this letter.

I'm lost. Any suggestions?

Thanks,
-Ted
 
Hi
Before constructing query-string,you have to convert to html-encode(if any non-english character).
So you can use these methods for conversion.
HttpUtility.htmlEncode
HttpUtility.htmlDecode

Thanks
Sakthivel
 
Back
Top