NLS编程

NLS(National Language Support)

Background(背景)

Each language has a language name and a language identifierthat indicate the particular code page (ANSI, DOS, Macintosh) used to represent the geographical location for the language on the operating system. 

Data Type(数据类型)

typedef WORD LANGID;
typedef DWORD LCID;
typedef DWORD LCTYPE;


Usage(使用)

Each locale has a unique identifier, a 32-bit value that consists of a language identifier and a sort order identifier. The locale identifier is a standard international numeric abbreviation and has the components necessary to uniquely identify one of the installed operating system-defined locales. 

The following illustration shows the format of the bits in a locale identifier.
+-------------+---------+-------------------------+
|   Reserved  | Sort ID |      Language ID        |
+-------------+---------+-------------------------+
31         20 19     16 15                      0   bit

The following illustration shows the format of the bits in a language identifier. 
+-------------------------+-------------------------+
|     SubLanguage ID      |   Primary Language ID   |
+-------------------------+-------------------------+
15                    10  9                         0   bit

Get LCID(locale indentifier)

LCID GetThreadLocale(void);


Modify customed LCID for thread
BOOL SetThreadLocale ( LCID Locale );

Compose LCID
DWORD MAKELCID(
	  WORD wLanguageID,  
	  WORD wSortID
	);
for sort order identifier, please refer to link.

Compose LANGID
WORD MAKELANGID(
	  USHORT usPrimaryLanguage,  
	  USHORT usSubLanguage       
	);

for languange identifier constants and strings, please refer to  link


Example:
SetThreadLocale(MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_GERMAN_PHONE_BOOK));

Extract Sort Identifier
WORD SORTIDFROMLCID(
	  LCID lcid  
	);

Extract Language Identifer
	WORD LANGIDFROMLCID(
	  LCID lcid  
	);

Extract Primary language identfier
	WORD PRIMARYLANGID(
	  WORD lgid  
	);

Extract a sublanguage identifier
	WORD SUBLANGID(
	  WORD lgid  
	);







 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值