Freigeben über


Response.LCID

The LCID property specifies how dates, times, and currencies are formatted. Locale identifiers (LCIDs) are not the same for each geographical locale. Some locales format dates as YY-MM-DD, and some format dates as MM-DD-YYYY. The LCID property is read/write.

Note

The locale group has to be installed on the Web server before its locale identifier can be specified in a Web page or application. Use the Regional and Language Options control panel application to install locale groups.

Syntax

Response.lcid [**=**LocaleID]

Parameters

  • LocaleID
    An integer representing the geographical locale. You can find locale-specific code page information on MSDN Library.

Applies To

Response Object

Remarks

Setting Response.LCID explicitly affects a single page, whereas setting Session.LCID affects all responses in a session.

If Response.LCID is not explicitly set on a page, it is implicitly set by Session.LCID, if sessions are enabled. If sessions are not enabled, Response.LCID is set by @LCID, if @LCID is present on the page. If there is no @LCID on the page, Response.LCID is set by the AspLCID metabase property. If the AspLCID property is not set, or set to 0, Response.LCID is set by the default system locale.

Response.LCID can be set multiple times in one Web page and used to format data each time. Some locales need the matching code page to be set to display characters properly. For example, to display dates and times in several locales on one page, the code page must be set to UTF-8 (65001) to show all the characters.

If you set Response.LCID or Session.LCID explicitly, do so before displaying formatted output. Setting Response.LCID changes the locale for both the ASP application and the scripting engine. Using the VBScript function setLocale() only changes the locale for the scripting engine.

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

If the locale is set in a page, and the code page is set to display the characters properly, Response.Charset should also be set. The code page value tells 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. For more information, see the lists of CharsetNames and matching code page values on MSDN Web Workshop under the columns for Preferred Charset Label and FamilyCodePage.

If you are writing and testing Web pages that use different locales, 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 and Language Options in the Control Panel.

Example Code

The following example displays the date, time, amount of money, and a decimal value in different locales. The code page is set to UTF-8 to display all the characters properly.

--- Response_LCID.asp ---

<% 
' This file does not need @LCID or @CODEPAGE and 
'  it does not need to be saved in UTF-8 format because  
'  there are no literal strings that need formatting or encoding. 

Response.Codepage = 65001 
Response.Charset = "utf-8" 

' See what happens when you uncomment the lines below. 
'Response.Codepage = 1252 
'Response.Charset = "windows-1252" 

ShowDateTimeCurrency 1033, "North America" 
ShowDateTimeCurrency 1041, "Japan" 
ShowDateTimeCurrency 1049, "Russia" 
ShowDateTimeCurrency 1031, "Germany" 
ShowDateTimeCurrency 1025, "Saudi Arabia" 
ShowDateTimeCurrency 1081, "India" 
ShowDateTimeCurrency 2052, "China" 
ShowDateTimeCurrency 1042, "Korea" 

Sub ShowDateTimeCurrency(iLCID, sLocale) 
  Response.LCID = iLCID 
  Response.Write "<B>" & sLocale & "</B><BR>" 
  Response.Write FormatDateTime(Date, 1) & "<BR>" 
  Response.Write FormatDateTime(Time, 3) & "<BR>" 
  Response.Write FormatCurrency(1000) & "<BR>" 
  Response.Write FormatNumber(50, 3, 0, 0, -1) & " & " & FormatNumber(.02, 3, 0, 0, -1) & "<BR><BR>" 
End Sub 
%> 

Requirements

Client: Requires or Windows XP Professional.

Server: Requires or Windows Server 2003.

Product: IIS

See Also