The 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 multi-byte characters, while others like English and German only need one byte to represent each character. The CodePage property is read/write.
Session.CodePage(=CodepageID)
Setting Session.CodePage explicitly affects all responses in a session. Session.CodePage sets Response.CodePage implicitly on each page. Sessions must be enabled to use Session.CodePage.
If Session.CodePage is not explicitly set in a page, it will be 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 codepage. 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 had the power to change the codepage for an entire session. Now, @CodePage and Response.CodePage affect only single responses, and Session.CodePage affects all responses in a session.
There can be only one codepage per response body, otherwise incorrect characters are displayed. If you set the codepage explicitly in two pages, where one is called by the other with #include, Server.Execute, or Server.Transfer, usually the parent page decides the codepage. 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 codepage.
Literal strings in a script are still encoded using @CodePage (if present) or the AspCodePage metabase value (if set), or the system ANSI codepage. If you set Response.CodePage or Session.CodePage explicitly, do so before sending non-literal strings to the client. If you use literal and non-literal strings in the same page, make sure the codepage of @CodePage matches the codepage of Session.CodePage, or the literal strings are encoded differently from the non-literal strings and displayed incorrectly.
If the codepage of your Web page matches the system defaults of the Web client, you do not need to set a codepage in your Web page. However, setting the value is recommended.
If the codepage is set in a page, then Response.Charset should also be set. The codepage value tells IIS how to encode the data when building the response, and the charset value tells the browser how to decode the data when displaying the response. The CharsetName of Response.Charset must match the codepage value, or mixed characters will be displayed in the browser. Lists of CharsetNames and matching codepage values can be found at 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.exe allows 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 in Regional Options from the Control Panel. For example, once you change your system locale to Japanese, any files you save in ANSI format will be saved using the Japanese codepage. They will only be readable from a Japanese System Locale.
If you are writing and testing Web pages that use different codepages and character sets (for example, creating a multi-lingual Web site), remember that your test client-computer must have the language packs installed for each language you wish to display. You can install language packs from Regional Options in the Control Panel.