## Setting the Locale Identifier

A locale is a set of user preference information related to the user's language. The locale determines how dates, times, currencies, and numbers are formatted, how items are alphabetically sorted, and how strings are compared. The locale identifier (LCID) is a 32-bit value that uniquely defines a locale. ASP uses the default locale of the Web server unless you specify a different locale for a particular script.

To specify the locale for an ASP page, use the AspLCID metabase property, the @LCID directive, the Session.LCID property, or the Response.LCID property. For example, to set the locale to Japanese, set the AspLCID property for your application to 1041 using one of the following commands:

    <%@ LCID = 1041 %>

    <% Session.LCID = 1041 %>

    <% Response.LCID = 1041 %>

Keep in mind that the codepage must be set to display any localized characters that are produced with calls to functions, for example ethe VBScript FormatCurrency and FormatDateTime. For example, if Response.LCID is set to 1041 for Japanese, Response.CodePage must be set to 932 in order to correctly display the month and day names from a call to FormatDateTime(Date, 1).

When a script is executed, Response.LCID determines how characters are encoded. If Response.LCID is not set explicitly in a Web page, then it is set implicitly with this hierarchy:

- If Sessions are enabled, and Session.LCID is set explicitly, Session.LCID sets Response.LCID . Else,
- If @LCID is defined at the top of the page, @LCID sets Response.LCID . Else,
- If the AspLCID metabase property for the application is set to something other than 0, AspLCID sets Response.LCID . Else,
- The Web server's default system locale sets Response.LCID .

Setting the locale using one of these methods also sets the locale for the scripting engine; however, setting the locale for the scripting engine with the VBScript function setLocale does not set the locale for ASP.

If you set the locale multiple times in a Web page, you need to set the codepage of that Web page to 65001 for UTF-8 and set Response.Charset to "utf-8", so all localized characters show up properly.

The following example is also found in the documentation for Response.LCID:

    <%
    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
    %>

For more examples and information, please see the documentation for AspLCID, @LCID, Session.LCID, Response.LCID, Response.Charset, and "International Features" in the "Windows Base Services" sectionof the Platform SDK.

© 1997-2001 Microsoft Corporation. All rights reserved.