setlocale 函数
sets the global locale and returns the previous locale.
setlocale(lcid)
lcid 参数可以是任意一个合法的 32 位数值或短字符串,该值必须唯一标识一个地理区域。能被识别的值可以查阅 区域设置 id 表。
说明
若 lcid 为零,区域被设置为与当前系统设置匹配。
一个 locale 是用户参考信息集合,与用户的语言、国家和文化传统有关。该 locale 决定键盘布局、字母排序顺序和日期、时间、数字与货币格式。
下面举例说明 setlocale 函数的用法。要使用该代码,请复制标准html 文件中 <body> 标志之间的所有内容。
enter date in uk format: <input type="text" id="ukdate" size="20"><p>
here's the us equivalent: <input type="text" id="usdate" size="20"><p>
<input type="button" value="convert" id="button1"><p>
enter a price in german: <input type="text" id="germannumber" size="20">
<p>
here's the uk equivalent: <input type="text" id="usnumber" size="20"><p>
<input type="button" value="convert" id="button2"><p><script language="vbscript">
dim currentlocale
' get the current locale
currentlocale = getlocalesub button1_onclick
dim original
original = setlocale("en-gb")
mydate = cdate(ukdate.value)
' ie always sets the locale to us english so use the
' currentlocale variable to set the locale to us english
original = setlocale(currentlocale)
usdate.value = formatdatetime(mydate,vbshortdate)
end subsub button2_onclick
dim original
original = setlocale("de")
myvalue = ccur(germannumber.value)
original = setlocale("en-gb")
usnumber.value = formatcurrency(myvalue)
end sub</script>