Freigeben über


Response.Charset

The Charset property appends the name of the character set (for example, ISO-8859-13) to the content-type header in the Response object.

Syntax

Response.Charset(CharsetName)

Parameters

  • CharsetName
    A string that specifies a character set for the page. The character set name is appended to the content-type header in the Response object.

Applies To

Response Object

Remarks

This property inserts any string in the header, regardless of whether it represents a valid character set.

If a single page contains multiple tags containing Response.Charset, each Response.Charset replaces the previous CharsetName. As a result, the character set is set to the value specified by the last instance of Response.Charset in the page.

If the code page of your Web page matches the system defaults of the Web client, you do not need to set a code page in your Web page. However, setting a code page is recommended.

If the code page is set by using Response.CodePage, Session.CodePage, @CodePage, or the AspCodePage metabase property, Response.Charset should also be used. The code page value specifies to IIS how to encode the data when building the response. The Charset value specifies to the browser how to decode the data when displaying the response. The CharsetName of Response.Charset must match the code page value or mixed characters are displayed in the browser. Lists of CharsetNames and matching code page values can be found on MSDN Web Workshop under the columns for Preferred Charset Label and FamilyCodePage.

If you are writing and testing Web pages that use different code pages and character sets (for example, if you were creating a multilingual Web site), remember that your test client computer must have the language packs installed for each language you want to display. You can install language packs from Regional Options in the Control Panel.

Example Code

For an ASP page that did not include the Response.Charset property, the content-type header would be as follows:

content-type:text/html

If the same .asp file included the following code:

<% Response.Charset= "ISO-8859-13" %>

The content-type header would be as follows:

content-type:text/html; charset=ISO-8859-13

Requirements

Client: Requires Windows XP Professional, Windows 2000 Professional, or Windows NT Workstation 4.0.

Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.

Product: IIS

See Also