UTF-8 and Server.URLEncode

Discussion in 'ASP General' started by burnsy2000, Jan 2, 2007.

  1. burnsy2000

    burnsy2000 Guest

    We are running ASP classic on IIS 5 on W2k SP4. We recently added <%
    Response.charset="utf-8"%> to the top of all our pages (as suggested by
    validator.w3.org). A problem arose on a page which applies
    Server.HTMLEncode to a field that was inputted from the user. The
    problem is that when the user enters a phrase such as:

    My Fiancé

    The Server.URLEncode returns the value:

    My Fiancé

    which doesn't appear correct. When I take out the <%
    Response.charset="utf-8"%> line, it returns

    My Fiancé

    which displays correctly. Am i ok to just leave out the <%
    Response.charset="utf-8"%> line, or should I use a different charset?
    or is there some other fix?
    burnsy2000, Jan 2, 2007
    #1
    1. Advertising


  2. >>>

    "burnsy2000" <> wrote in message
    news:...
    We are running ASP classic on IIS 5 on W2k SP4. We recently added <%
    Response.charset="utf-8"%> to the top of all our pages (as suggested by
    validator.w3.org).
    <<<

    You also require Session.CodePage = 65001.

    >>>

    A problem arose on a page which applies
    Server.HTMLEncode to a field that was inputted from the user. The
    problem is that when the user enters a phrase such as:

    My Fiancé

    The Server.URLEncode returns the value:

    My Fiancé

    <<<

    I think you are confusing URLEncode with HTMLEncode. The output is
    consistent with HTMLEncode. What you are seeing here is the posted form
    data being formatted as UTF-8 but being read by the server as 1252 (or
    whatever your default OEM codepage is).


    >>>

    which doesn't appear correct. When I take out the <%
    Response.charset="utf-8"%> line, it returns

    My Fiancé

    which displays correctly. Am i ok to just leave out the <%
    Response.charset="utf-8"%> line, or should I use a different charset?
    or is there some other fix?
    <<<


    If you ensure ALL pages Begin with Session.CodePage = 65001 and
    Response.CharSet = "UTF-8" your problems should go away. (Note if you have
    been saving results of form posts to a DB you may well have corrupt entiries
    in your DB)

    Anthony.
    Anthony Jones, Jan 3, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Klemt
    Replies:
    4
    Views:
    10,266
    mikeb
    Jan 22, 2004
  2. Dario Sala
    Replies:
    1
    Views:
    3,778
    Karl Seguin
    Nov 15, 2004
  3. Replies:
    1
    Views:
    1,084
    Rob Schieber
    Sep 30, 2005
  4. MyndPhlyp
    Replies:
    3
    Views:
    479
    MyndPhlyp
    Oct 3, 2005
  5. InvestorTrade
    Replies:
    2
    Views:
    320
    InvestorTrade
    Mar 3, 2008
Loading...

Share This Page