Strange behaviour with UTF-8 encoding

Discussion in 'ASP General' started by liam_weston@hotmail.com, Feb 10, 2006.

  1. Guest

    I have 2 supposedly identical Windows 2000 web servers each with IIS5.
    Both have the ASPCODEPAGE set to 65001 (utf-8) in the metabase. The
    first server has been running pages like the one below for a long time
    and the output has been correct ie. the ™ character and international
    characters have displayed correctly (except that the ™ has never
    displayed correctly in the titlebar). My problem is that the second
    server is not displaying these characters correctly. Here's an example
    of the asp code:

    ***********************************************************************
    <%@ Language=VBScript%>

    <%Response.CharSet = "utf-8"%>

    <HTML>
    <HEAD>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8;">


    <TITLE>Tradename™</TITLE>

    </HEAD>

    <body>
    Náttúruverndarsvæði Tradename™
    </body>
    </HTML>
    *************************************************************************

    The ™ displays as ? and the icelandic characters are garbled. If I
    choose View > Encoding > Autoselect (turn off autoselect) and then View
    > Encoding > Autoselect (turn on autoselect) IE6 selects Western European rather than utf-8 and the page is correct (including the titlebar).


    I have discovered that if I save the asp file as UTF-8 in notepad the
    characters display correctly.

    Here's the strange thing.. Although existing pages on the first server
    are working fine, if I create the above test page these characters are
    wrong on that server too. Once again if I save it as utf-8 it works. I
    have opened some of the old pages in notepad and tried File > Save As
    to see what their current encoding is and it is always ANSI, which
    according to the new tests I'm running, should not work..

    Also, if I copy a working page from server 1 to server 2 it doesnt work
    on server 2 so it can't be the encoding of the file.

    So my question is why would one page with the same character, the same
    charset in the page and the same file encoding be rendered differently?
    Is there a configuration setting I have missed that forces ASP pages to
    be encoded in utf-8?

    I would appreciate your comments.

    Thanks
     
    , Feb 10, 2006
    #1
    1. Advertising

  2. Guest

    Ah... looks like the encoding of this page is messing with the
    characters too!

    The character I'm having problems with is © (the trademark symbol)
    and the icelandic character set (see
    http://www.icetourist.is/default.asp?cat_id=1 for an example). I
    realise I can simply use the © code instead of the TM but the
    icelandic is more of a problem.
     
    , Feb 10, 2006
    #2
    1. Advertising

  3. Guest

    I meant "™" for TM
     
    , Feb 10, 2006
    #3
  4. Guest

    Further info.. the code example above doesn't work on any server
    because it needs to be output in a response.write to pick up the
    response.charset. This still doesn't work on my second server.

    ***********************************************************************

    <%@ Language=VBScript%>

    <%Response.CharSet = "utf-8"%>

    <HTML>
    <HEAD>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8;">

    <%= "<TITLE>Trademark&trade;</TITLE>"%>

    </HEAD>

    <body>
    <%= "Trademark&trade;"%>
    </body>
    </HTML>
    *************************************************************************
     
    , Feb 10, 2006
    #4
  5. Guest

    I finally solved this problem. Session state wasn't enabled in IIS

    Properties > Home Directory > Configuration > App Options > Tick the
    Enable Session State checkbox

    My understanding of this is that the codepage declaration is held in
    the session and if one isnt enabled it gets ignored. If anybody can
    give me a better explanation Id be interested to hear.
     
    , Feb 13, 2006
    #5
    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. Antonio

    Strange encoding behaviour

    Antonio, Dec 29, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    429
    Antonio
    Dec 29, 2004
  2. Antonio

    Strange encoding behaviour

    Antonio, Dec 29, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    304
    Antonio
    Dec 29, 2004
  3. Antonio

    Strange encoding behaviour

    Antonio, Dec 29, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    321
    Antonio
    Dec 29, 2004
  4. Replies:
    2
    Views:
    378
  5. Replies:
    2
    Views:
    388
    Nathan Keel
    Aug 14, 2009
Loading...

Share This Page