UTF-8 and Server.URLEncode

B

burnsy2000

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?
 
A

Anthony Jones

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

MeCab UTF-8 Decoding Problem 6
UTF-8 read & print? 6
UTF-8 and strings 44
hex dump w/ or w/out utf-8 chars 40
Server.HTMLEncode with UTF-8 1
Strange behaviour with UTF-8 encoding 4
CGI and UTF-8 14
iso-8859-1 and UTF-8 3

Staff online

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top