Locale is a set of settings specific to a country or region, including character sets, numbers, currencies, time, and date formats. In Windows, each locale can be represented by a 32-bit number and recorded as lcid. In winnt. H, we can see the composition of lcid. Its high 16-bit character sorting method is generally 0. In its low 16 bits, the low 10 bits are the ID of primary language, and the high 4 bits specify sublanguage. Sublanguage is used to distinguish different encodings in the same language. The constant definitions of some primary language and sublanguage are as follows:
# Define lang_chinese 0x04
# Define lang_english 0x09
# Define lang_french 0x0c
# Define lang_german 0x07
# Define sublang_chinese_traditional 0x01 // Chinese (Taiwan Region)
# Define sublang_chinese_simplified 0x02 // Chinese (PR China)
# Define sublang_english_us 0x01 // english (USA)
# Define sublang_english_uk 0x02 // english (UK)
Now we can calculate the lcid of Simplified Chinese, and shift the constant of sublanguage to the left by 10 digits, that is, multiply by 1024, plus the constant of primary language: the hexadecimal value of 2*1024 + 4 = 2052,16 is 0804. In American English: 1*1024 + 9 = 1033,16, The hexadecimal value is 0409 .. Traditional Chinese is 1*1024 + 4 = 0404, and hexadecimal is.