2025-04-27 07:49:33 -04:00

112 lines
5.6 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
<TITLE>Setting the Locale Identifier</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
TempString = navigator.appVersion
if (navigator.appName == "Microsoft Internet Explorer"){
// Check to see if browser is Microsoft
if (TempString.indexOf ("4.") >= 0){
// Check to see if it is IE 4
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
}
else {
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
}
}
else if (navigator.appName == "Netscape") {
// Check to see if browser is Netscape
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
}
else
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
//-->
</script>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Window_OnLoad()
Dim frmContents
On Error Resume Next
If Not Parent Is Nothing Then
Set frmContents = Parent.Contents
If Not frmContents Is Nothing Then
frmContents.Window.TOCSynch_Click
End If
End If
End Sub
//--></SCRIPT><META NAME="DESCRIPTION" CONTENT="Internet Information Services reference information">
<META HTTP-EQUIV="PICS-Label" CONTENT='(PICS-1.1 "<http://www.rsac.org/ratingsv01.html>" l comment "RSACi North America Server" by "inet@microsoft.com <mailto:inet@microsoft.com>" r (n 0 s 0 v 0 l 0))'>
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META NAME="MS-IT-LOC" Content="Internet Information Services">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H2><A NAME="_k2_setting_the_locale_identifier"></A><SUP></SUP>Setting the Locale Identifier</H2>
<P>A <I>locale</I> 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 <I>locale identifier</I> (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.</P>
<P>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:</P>
<PRE><CODE>&lt;%@ LCID = 1041 %&gt;
&lt;% Session.LCID = 1041 %&gt;
&lt;% Response.LCID = 1041 %&gt;
</CODE></PRE>
<P>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).</P>
<P>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:
<UL type=disc>
<LI>If Sessions are enabled, and Session.LCID is set explicitly, Session.LCID sets Response.LCID . Else,</li>
<LI>If @LCID is defined at the top of the page, @LCID sets Response.LCID . Else,</li>
<LI>If the AspLCID metabase property for the application is set to something other than 0, AspLCID sets Response.LCID . Else,</li>
<LI>The Web server's default system locale sets Response.LCID .</li>
</UL>
<P>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 <B>setLocale</B> does not set the locale for ASP.</P>
<P>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.</P>
<P>The following example is also found in the documentation for Response.LCID:</P>
<PRE><CODE>&lt;%
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 "&lt;B&gt;" &amp; sLocale &amp; "&lt;/B&gt;&lt;BR&gt;"
Response.Write FormatDateTime(Date, 1) &amp; "&lt;BR&gt;"
Response.Write FormatDateTime(Time, 3) &amp; "&lt;BR&gt;"
Response.Write FormatCurrency(1000) &amp; "&lt;BR&gt;"
Response.Write FormatNumber(50, 3, 0, 0, -1) &amp; " &amp; " &amp; FormatNumber(.02, 3, 0, 0, -1) &amp; "&lt;BR&gt;&lt;BR&gt;"
End Sub
%&gt;</CODE></PRE>
<P>For more examples and information, please see the documentation for <A HREF="apro4ysk.htm">AspLCID</A>, <A HREF="dire8dr8.htm">@LCID</A>, <A HREF="vbob72uc.htm">Session.LCID</A>, <A HREF="vbob055w.htm">Response.LCID</A>, <A HREF="vbob7fw4.htm">Response.Charset</A>, and "International Features" in the "Windows Base Services" sectionof the Platform SDK.</P>
<hr class="iis" size="1">
<p align="center"><em><a href="../../../common/colegal.htm">&copy; 1997-2001 Microsoft Corporation. All rights reserved.</a></em></p>
</BODY>
</HTML>