Classic ASP text substitution and UTF-8 encoding

Derek Ekins picture Derek Ekins · Sep 21, 2009 · Viewed 50.4k times · Source

We have a website that uses Classic ASP.

Part of our release process substitutes values in a file and we found a bug in it where it will write the file out as UTF-8.

This then causes our application to start spitting out garbage. Apostrophes get returned as some encoded characters.

If we then go an remove the BOM that says this file is UTF-8 then the text that was previously rendered as garbage is now displayed correctly.

Is there something that IIS does differently when it encounters UTF-8 a file?

Answer

Werewolf picture Werewolf · Aug 25, 2011

I was searching on the same exact issue yesterday and came across:

http://blog.inspired.no/utf-8-with-asp-71/

Important part from that page, in case it goes away...

ASP CODE:

Response.ContentType = "text/html"
Response.AddHeader "Content-Type", "text/html;charset=UTF-8"
Response.CodePage = 65001
Response.CharSet = "UTF-8"

and the following HTML META tag:

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />

We were using the meta tag and asp CharSet property, yet the page still didn't render correctly. After adding the other three lines to the asp file everything just worked.

Hope this helps!