Using the Locale Identifier (LCID) (2)

In Part 1 we discussed how the Web server's regional settings (editable by the Administrator through the Control Panel's Regional Options icon) affect the output of VBScript's Format functions. In this part we'll look at using the Session.LCID property to change this default locale on a user-by-user (or Web page-by-Web page) basis! <br>
<br>
Setting the Locale ID on a User-by-User Basis:<br>
While the default locale setting dictates the output of the Format functions, what if you want to have the output differ based on the person visiting the page? (Perhaps you run a site where the user can customize the output or content presented, a site like My Yahoo! or any of the other customizable portals.) One option is to use the LCID property of the Session object (LCID stands for Locale Identifier). For example, you can specify the Locale for a particular user to be Estonian by using the following code: <br>
<br>
Session.LCID = 1061 'Estonian Locale ID  <br>
<br>
<br>
Now, you may be wondering how in the world I knew that Estonian's LCID was 1061. The simplest way is to consult Microsoft's LCID table. This handy table contains a listing of all of the various locales and their associated IDs. By simply changing this locale ID, the output for the VBScript Format functions will change for the particular user. Using this property you can automatically have the Format functions' output change based on the user's LCID. <br>
<br>
One thing to be wary of is currency issues. For example, if I am running an English eCommerce site and have my Web server's regional settings set to English - United States by default, I may have some code that looks like this: <br>
<br>
Shoes cost: <%=FormatCurrency(45.56)%>  <br>
<br>
<br>
Since, in this hypothetical example, I run an eCommerce site in the US, I mean that the cost for the shoes are 45 dollars and 56 cents. However, if set a user's Session.LCID property to, say, 2057 (English - United Kingdom), the shoes would appear to cost 45.56 pounds! Therefore, if you plan on altering the LCID settings I strongly encourage that you do not use the FormatCurrency function or, if you do, that instead of passing a hard-coded value into the function you pass in the result of some currency exchange rate calculation function: <br>
<br>
Shoes cost: <%=FormatCurrency(ConvertFromDollars(45.56))%>  <br>
<br>
<br>
The ConvertFromDollar function would then consult the Session.LCID property to determine what currency we were converting our dollars to. (You would then need to use some component like iisCARTex to perform the actual currency conversion.) <br>
<br>
Setting the Locale ID on a Page-by-Page Basis:<br>
You can also specify the LCID for an entire ASP page instead of on a user-by-user basis. For example, if you had a Web page on your site that, for some reason, you wanted to always use the Hebrew formatting style (LCID 1037) you could do so via the @LCID directive. As with the other ASP directives (@LANGUAGE, @ENABLESESSIONSTATE, etc.), the @LCID directive must appear before any ASP or HTML code. For example, to set an ASP page's LCID to 1037 (Hebrew), we could use the following code: <br>
<br>
<%@LCID=1037%> <br>
<br>
<br>
or, if we wished to specify multiple directives, we could do: <br>
<br>
<%@LANGUAGE="VBSCRIPT" LCID=1037%> <br>
<br>
<br>
That's all there is to it! <br>
<br>
Conclusion:<br>
In this article we examined how to set the default locale settings through the Regional Options icon in the Web server's Control Panel. This locale default determines how VBScript's Format functions produce their output. Any locale setting can be fully customized for a very unique look and feel for representing numbers, dates and times, and currencies. ASP also provides a Locale ID on both a user-by-user basis and a page-by-page basis. To specify a locale ID (LCID) for a particular user, set the Session.LCID property to the appropriate numeric ID. To set the LCID for a particular ASP page, use the @LCID directive. (For a listing of the various LCIDs and their respective values, check out the LCID table.) <br>
<br>
Happy Programming! <br>
<br>

时间: 2024-12-02 18:20:19

Using the Locale Identifier (LCID) (2)的相关文章

Using the Locale Identifier (LCID) (1)

Introduction:When you use the VBScript functions FormatNumber, FormatDateTime, and FormatCurrency, the output displayed is based upon the regional settings of your Web server. (To learn more about these functions check out the technical docs (FormatC

LCMapString函数

LCMapString函数 The LCMapString function either maps an input character string to another using a specified transformation or generates a sort key for the input string. 定义 int LCMapString(LCID Locale, DWORD dwMapFlags, LPCTSTR lpSrcStr, int cchSrc, LPT

Windows数据类型探幽

Windows 数据类型(一)   由微软 Windows 操作系统所支持的各种数据类型是用来定义函数的返回值.函数和消息的参数以及结构体成员(因为 Win32 程序是用 C 语言来编写,所以没有"类"这个概念)的.这些数据类型定义了上述元素的尺码(在内存中的,也就是占用内存的字节数)和含义.笔者以前一直不太注意这些东西,结果在程序设计时可谓步履维艰.不同类型的常 / 变量,在程序用扮演的角色相去甚远,了解这些类型,对剖析程序的工作原理是非常有用的.今天又是周末,我把这些类型列出来,然

关于SetLocaleInfo()

原文:关于SetLocaleInfo() 此函数用于设置系统的一些本地信息, 非常有用. 比如日期格式为'yyyy/mm/dd'时, 稍微不注意,有些程序语句会报错. 以下资料网络收集: 1. SetLocaleInfo()中 LCTYPE values 的具体意义    出自: http://hi.baidu.com/stormsxf/blog/item/7395b3000ed2e015728b65a5.html BOOL SetLocaleInfo(LCID Locale, LCTYPE L

asp入门教程:ASP applocation 全局变量与 Global.asa 文件

asp入门教程:ASP 全局变量 Global.asa 文件 Global.asa文件是一个可选文件,可以包含申报的对象,变量和方法,可以通过在每一页的ASP应用程序. -------------------------------------------------- ------------------------------ Global.asa文件 Global.asa文件是一个可选文件,可以包含申报的对象,变量和方法,可以通过在每一页的ASP应用程序.所有有效的浏览器的脚本( Java

脚本的DVD开发_其它

好像包含表格不能发表,只有先拷贝到记事本里面才可以,所以格式都丢了,不好意思 这个也是很久以前的东西了,不准确的地方还请大家见谅.哎,我的一本书没有被出版,就放到这里吧(出版社的人说看不懂,呵呵,我都快晕死了) 基于脚本的dvd应用程序 在网络发展神速的今天,软件业越来越注重基于网络的应用,下来我们就探讨一下基于web的程序编写.这里主要讲述使用mswebdvd控件进行dvd应用程序的开发过程.  插入MSWebDVD对象 MSWebDVD对象可以处理所有的dvd导航命令,并可以在web页面上显

DirectX--Filter属性页的调用

IEnumFilters* pEnum; HRESULT hr ; if (pigb) { hr = pigb-> EnumFilters(&pEnum); if (FAILED(hr))  { return ; }       IBaseFilter* pFilter = NULL; while (pEnum->Next(1, &pFilter, NULL) == S_OK)  { // Check for required interface IUnknown* pUnk;

数据库连接大全

-----------MySQL 连接方式----------- MySQL Connector/ODBC 2.50 (MyODBC 2.50)连接方式本地数据库连接Driver={mySQL};Server=localhost;Option=16834;Database=myDataBase; 远程数据连接:Driver={mySQL};Server=myServerAddress;Option=131072;Stmt=;Database=myDataBase; User=myUsername

directX播放程序

enum PLAYSTATE {Stopped, Paused, Running, Init};PLAYSTATE g_Current=Init; HWND      ghApp;HINSTANCE ghInst;HRESULT   hr;LONG      evCode;LONG      evParam1;LONG      evParam2;  //HRESULT  hr; IGraphBuilder *pigb  = NULL; IMediaControl *pimc  = NULL;