Session.LCID

LCID属性指定了如何格式化日期、时间和货币。本地标识符(LCID)与每个地理位置不同。一些地方把日期格式化为YY_MM-DD,另一些地方则把日期格式化为MM-DD-YYYY。LCID属性是可读可写的。

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 theRegional and Language Options control panel application to install locale groups.

句法

Session.LCID(= LocaleID)

参数

LocaleID
一个整型数,代表地理位置。你可以在MSDN Library上找到本地整型数。

适用于

Session对象

备注

设置Session.LCID会明确影响会话中所有的响应。

If Session.LCID is not explicitly set in a page, it is implicitly set by the AspLCID metabase property. If the AspLCID metabase property is not set, or set to 0, Session.LCID is set by the default system locale.

Session.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 Session.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.

如果Web网页的位置匹配Web客户端的系统默认值,你不需要在Web网页中设置位置。然而,依然建议设置该值。

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

如果你正在编写并测试使用不同位置、不同code page和不同字符集的网页(例如,如果你正在创建一个多语言Web网站),请记住你的测试客户端计算机必须已经安装每种你想显示的语言的语言包。你可以在控制面板的区域和语言选项中安装语言包。

示例代码

下面的示例演示了把位置设置为英国英语,使用VBScript的FormatCurrenty方法来把125值显示不货币,带有£符号:

<% 
  Session.LCID = 2057 
  Dim curNumb 
  curNumb = FormatCurrency(125) 
  Response.Write (curNumb) 
>

必备条件

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

如果你喜欢这篇文章,敬请给站长打赏↑

除特别注明外,本站所有文章均为本站站长原译,转载请注明出处。