Export (0) Print
Expand All

Session.CodePage

IIS 6.0

For all responses in a session, the Session.CodePage property specifies how strings are encoded in the intrinsic objects. A code page is a character set that can include numbers, punctuation marks, and other glyphs. Codepages are not the same for each language. Some languages, such as Japanese and Hindi, have multibyte characters, while others, such as English and German, only need one byte to represent each character. The CodePage property is read/write.

Session.CodePage(=CodepageID)

CodepageID

An integer that represents the character formatting code page. You can find code page integers on MSDN Web Workshop under the column for FamilyCodePage.

Setting Session.CodePage explicitly affects all responses in a session. Session.CodePage sets Response.CodePage implicitly on each page. Session must be enabled to use Session.CodePage.

If Session.CodePage is not explicitly set on a page, it is implicitly set by the AspCodePage metabase property. If the AspCodePage property is not set, or set to 0, Session.CodePage is set by the system ANSI code page. Session.CodePage is no longer implicitly set by @CodePage, as it was for IIS 5.0 and earlier versions. This change was made because one @CodePage could change the code page for an entire session. Now, @CodePage and Response.CodePage affect only single responses, while Session.CodePage affects all responses in a session.

There can be only one code page per response body, otherwise incorrect characters are displayed. If you set the code page explicitly in two pages, where one is called by the other by using #include, Server.Execute, or Server.Transfer, usually the parent page decides the code page. The only exception is if Response.CodePage is explicitly set in the parent page of a Server.Execute call. In that case, an @CodePage command in the child page overrides the parent code page.

Literal strings in a script are still encoded by using @CodePage (if present) or the AspCodePage metabase value (if set), or the system ANSI code page. If you set Response.CodePage or Session.CodePage explicitly, do so before sending nonliteral strings to the client. If you use literal and nonliteral strings in the same page, make sure the code page of @CodePage matches the code page of Session.CodePage, or the literal strings are encoded differently from the nonliteral strings and displayed incorrectly.

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 the value is recommended.

If the code page is set in a page, Response.Charset also should be set. The code page value specifies to IIS how to encode the data when building the response; and 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.

The file format of a Web page must be the same as the @CodePage used in the page. Notepad enables you to save files in UTF-8 format or in the system ANSI format. For example, if @CodePage is set to 65001 for UTF-8, the Web file must be saved in UTF-8 format. If @CodePage is set to 1252, the Web file must be saved in ANSI format on an English or German system. If you want to save a page in the ANSI format for a language other than your system language, you can change your default System Locale settings in Regional and Language Options on the Control Panel. For example, after you change your system locale to Japanese, any files you save in ANSI format are saved using the Japanese code page. They will only be readable from a Japanese system locale.

If you are writing and testing Web pages that use different code pages and character sets (for example, if you are 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 the Regional and Language Options in the Control Panel.

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

Show:
© 2014 Microsoft