Results 1 to 2 of 2

Thread: Decoding special characters with Request.QueryString.Item

  1. #1
    tedweatherly is offline VB.NET Forum Newbie
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Jun 2009
    Posts
    1
    Reputation
    0

    Question Decoding special characters with Request.QueryString.Item

    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

  2. #2
    sakthimp is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5
    Join Date
    Jun 2010
    Posts
    2
    Reputation
    0
    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

Tags for this Thread

Bookmarks

Posting Permissions

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