国际化编程中Locale相关概念的一些解释

<iframe align="top" marginwidth="0" marginheight="0" src="http://www.zealware.com/46860.html" frameborder="0" width="468" scrolling="no" height="60"></iframe>

Locales

一般常用的并且容易造成混淆的Locale3种:System Locale, User Locale, Thread Locale

1. System Locale:系统区域设置。决定了非Unicode程序所使用的代码页,如下:

<shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="[email protected]@[email protected]@[email protected]@[email protected]@5xe" filled="f" stroked="f"><stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></path><lock v:ext="edit" aspectratio="t"></lock></shapetype><shape id="Picture_x0020_1" style="VISIBILITY: visible; WIDTH: 301.5pt; HEIGHT: 225pt; mso-wrap-style: square" o:spid="_x0000_i1026" type="#_x0000_t75"><imagedata src="file:///D:%5Ctmp%5Cmsohtmlclip1%5C01%5Cclip_image001.png" o:title=""></imagedata></shape>

国际化编程中Locale相关概念的一些解释

System Locale对应的Code Page可以用GetACPGetOEMCP来获得。System Locale无法被API修改 ,但是可以用GetSystemDefaultLCIDGetSystemDefaultLangID获得。LCIDLangID后面会解释。

2. User Locale:用户区域设置,决定了各种标准和格式的定义,如数字,日期等,如下:

<shape id="Picture_x0020_2" style="VISIBILITY: visible; WIDTH: 300.75pt; HEIGHT: 159pt; mso-wrap-style: square" o:spid="_x0000_i1025" type="#_x0000_t75"><imagedata src="file:///D:%5Ctmp%5Cmsohtmlclip1%5C01%5Cclip_image003.png" o:title=""></imagedata></shape>

国际化编程中Locale相关概念的一些解释

User Locale是不能被API修改的,只能由用户设置。可以通过GetUserDefaultLCIDGetUserDefaultLangID获得。同样的,区别后面会提到。

3. Thread Locale:线程相关的区域。初始值为当前的User Locale,可以使用GetThreadLocaleSetThreadLocale获取和修改。

LANGID & LCID

1. LANGIDLanguage ID,也就是语言ID。代表不同的语言,比如EnglishChinese,等等。Lang ID (16 bit)=Primary Language ID(10 bit) + Sub Language ID(6 bit),如下:

Sub Language ID:6

Primary Language ID:10

PrimaryLanguage代表主语言,比如英语

Sub Language代表子语言,也就是语言的亚种,如美式英语 (en-us),或者英式英语(en-gb),对应的子语言为us/gb

2. LCIDLocale Identifier,代表Locale信息,等价于LANGID (16 bit) + Sort ID (4bit) + Reserved (12),如下:

Reserved : 16

Sort ID : 4

LANG ID: 16

作者: ATField
Blog:
http://blog.csdn.net/atfield
转载请注明出处

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1564059