Name

Charset — Response.Charset( strCharsetName )

Synopsis

The Charset allows you to specify a character set for the HTTP response content. The name of this character set is added to the end of the Content-Type header/value pair in the HTTP response headers.

Parameters

strCharsetName

The strCharsetName is a string corresponding to a character set. The default character set is ISO-LATIN-1.

Example

If you do not set the Charset property, the Content-Type HTTP response header looks like the following:

content-type:text/html

If you set the Charset property, as in the following line of code:

<%
Response.Charset("ISO-LATIN-7")
%>

the value you use to set the Charset property value (the string "ISO-LATIN-7" in the preceding code) is appended to the end of the Content-Type HTTP response header value:

content-type:text/html;charset=ISO-LATIN-7

Notes

Although Charset is referred to in both this book and the Microsoft documentation as a property, it is really a method that takes a string argument representing the name of the charset to be added to the end of the Content-Type HTTP response header. For this reason, if you attempt to set the value of the Charset "property" as you would any other Response object property, you will receive an error:

<%
' Next line will NOT work:
Response.Charset = "ISO-LATIN-7"
%>

If the value you set for the Charset property does not represent a valid character set, this value is ignored by the client's browser, and the default character set is used instead.

Note that you ...

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.