The Content-Type meta header informs the browser to treat the content sent as a UTF-8 encoded text stream. It doesn't ensure that the stream sent is actually UTF-8. To handle UTF-8 correctly you need to do 3 things:-
- Ensure your static content is saved in a UTF-8 compatible encoding.
- Ensure your dynamic content is encoded to UTF-8.
- Inform the client that the content is UTF-8 encoded.
Item 1 requires either that you actually save the ASP file as a UTF-8 encoded file or that all your static content in the file is within the ASCII character range (0-127). Note if you save as UTF-8 then all your server-side script must use characters within the ASCII character range.
Item 2 requires that the Response.CodePage
property is set to the UTF-8 code page 65001, you can do this in code or by adding the attribute CODEPAGE=65001
to the <%@ %>
declarations on the first line of the ASP file. If you do it in code you must set it before any calls to Response.Write
.
Item 3 requires that the Content-Type
header contains the charset=UTF-8
qualifier. As you are already doing you can do this with the META header. Personally I find that to be a bit of kludge, I prefer to use Response.Charset = "UTF-8"
in code. This places the qualifier on the true Content-Type
HTTP header.