UTF-8 and Server.URLEncode
am 02.01.2007 18:44:48 von burnsy2000
We are running ASP classic on IIS 5 on W2k SP4. We recently added <%
Response.charset=3D"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=E9
The Server.URLEncode returns the value:
My Fiancé
which doesn't appear correct. When I take out the <%
Response.charset=3D"utf-8"%> line, it returns
My Fiancé
which displays correctly. Am i ok to just leave out the <%
Response.charset=3D"utf-8"%> line, or should I use a different charset?
or is there some other fix?
Re: UTF-8 and Server.URLEncode
am 03.01.2007 14:11:59 von Anthony Jones
>>>
"burnsy2000" wrote in message
news:1167759888.385952.54540@s34g2000cwa.googlegroups.com...
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.