Created
June 10, 2021 18:34
-
-
Save vadz/5827c77be02c3f7e928c03867ead13c4 to your computer and use it in GitHub Desktop.
Show value of some, or all, MSW locale settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define UNICODE | |
#define WIN32_LEAN_AND_MEAN | |
#include <windows.h> | |
#include <strsafe.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <wchar.h> | |
struct LocaleOption | |
{ | |
const char* name; | |
LCTYPE type; | |
const wchar_t* desc; | |
const wchar_t* GetValue() const | |
{ | |
static wchar_t buf[256]; | |
constexpr auto size = sizeof(buf)/sizeof(buf[0]); | |
if (!::GetLocaleInfoW(LOCALE_USER_DEFAULT, type, buf, size)) { | |
StringCchPrintfW(buf, size, L"*** ERROR %08x", ::GetLastError()); | |
} | |
return buf; | |
} | |
}; | |
const LocaleOption localeOptions[] = { | |
{ "LOCALE_ILANGUAGE", 0x00000001, LR""(DEPRECATED language id (LCID), LOCALE_SNAME preferred)"" }, | |
{ "LOCALE_SLOCALIZEDDISPLAYNAME", 0x00000002, LR""(localized name of locale, eg "German (Germany)" in UI language)"" }, | |
{ "LOCALE_SABBREVLANGNAME", 0x00000003, LR""(DEPRECATED arbitrary abbreviated language name, LOCALE_SISO639LANGNAME instead.)"" }, | |
{ "LOCALE_SNATIVELANGUAGENAME", 0x00000004, LR""(native name of language, eg "Deutsch")"" }, | |
{ "LOCALE_IDIALINGCODE", 0x00000005, LR""(country/region dialing code, example: en-US and en-CA return 1.)"" }, | |
{ "LOCALE_SLOCALIZEDCOUNTRYNAME", 0x00000006, LR""(localized name of country/region, eg "Germany" in UI language)"" }, | |
{ "LOCALE_SABBREVCTRYNAME", 0x00000007, LR""(DEPRECATED arbitrary abbreviated country/region name, LOCALE_SISO3166CTRYNAME instead.)"" }, | |
{ "LOCALE_SNATIVECOUNTRYNAME", 0x00000008, LR""(native name of country/region, eg "Deutschland")"" }, | |
{ "LOCALE_IDEFAULTLANGUAGE", 0x00000009, LR""(DEPRECATED default language id, deprecated)"" }, | |
{ "LOCALE_IDEFAULTCOUNTRY", 0x0000000A, LR""(DEPRECATED default country/region code, deprecated)"" }, | |
{ "LOCALE_IDEFAULTCODEPAGE", 0x0000000B, LR""(default oem code page for locale (user may configure as UTF-8, use of Unicode is recommended instead))"" }, | |
{ "LOCALE_SLIST", 0x0000000C, LR""(list item separator, eg "," for "1,2,3,4")"" }, | |
{ "LOCALE_IMEASURE", 0x0000000D, LR""(0 = metric, 1 = US measurement system)"" }, | |
{ "LOCALE_SDECIMAL", 0x0000000E, LR""(decimal separator, eg "." for 1,234.00)"" }, | |
{ "LOCALE_STHOUSAND", 0x0000000F, LR""(thousand separator, eg "," for 1,234.00)"" }, | |
{ "LOCALE_SGROUPING", 0x00000010, LR""(digit grouping, eg "3;0" for 1,000,000)"" }, | |
{ "LOCALE_IDIGITS", 0x00000011, LR""(number of fractional digits eg 2 for 1.00)"" }, | |
{ "LOCALE_ILZERO", 0x00000012, LR""(leading zeros for decimal, 0 for .97, 1 for 0.97)"" }, | |
{ "LOCALE_SNATIVEDIGITS", 0x00000013, LR""(native digits for 0-9, eg "0123456789")"" }, | |
{ "LOCALE_SCURRENCY", 0x00000014, LR""(local monetary symbol, eg "$")"" }, | |
{ "LOCALE_SINTLSYMBOL", 0x00000015, LR""(intl monetary symbol, eg "USD")"" }, | |
{ "LOCALE_SMONDECIMALSEP", 0x00000016, LR""(monetary decimal separator, eg "." for $1,234.00)"" }, | |
{ "LOCALE_SMONTHOUSANDSEP", 0x00000017, LR""(monetary thousand separator, eg "," for $1,234.00)"" }, | |
{ "LOCALE_SMONGROUPING", 0x00000018, LR""(monetary grouping, eg "3;0" for $1,000,000.00)"" }, | |
{ "LOCALE_ICURRDIGITS", 0x00000019, LR""(# local monetary digits, eg 2 for $1.00)"" }, | |
{ "LOCALE_IINTLCURRDIGITS", 0x0000001A, LR""(DEPRECATED, use LOCALE_ICURRDIGITS # intl monetary digits, eg 2 for $1.00)"" }, | |
{ "LOCALE_ICURRENCY", 0x0000001B, LR""(positive currency mode, 0-3, see documentation)"" }, | |
{ "LOCALE_INEGCURR", 0x0000001C, LR""(negative currency mode, 0-15, see documentation)"" }, | |
{ "LOCALE_SDATE", 0x0000001D, LR""(DEPRECATED date separator (derived from LOCALE_SSHORTDATE, use that instead))"" }, | |
{ "LOCALE_STIME", 0x0000001E, LR""(DEPRECATED time separator (derived from LOCALE_STIMEFORMAT, use that instead))"" }, | |
{ "LOCALE_SSHORTDATE", 0x0000001F, LR""(short date format string, eg "MM/dd/yyyy")"" }, | |
{ "LOCALE_SLONGDATE", 0x00000020, LR""(long date format string, eg "dddd, MMMM dd, yyyy")"" }, | |
{ "LOCALE_IDATE", 0x00000021, LR""(DEPRECATED short date format ordering (derived from LOCALE_SSHORTDATE, use that instead))"" }, | |
{ "LOCALE_ILDATE", 0x00000022, LR""(DEPRECATED long date format ordering (derived from LOCALE_SLONGDATE, use that instead))"" }, | |
{ "LOCALE_ITIME", 0x00000023, LR""(DEPRECATED time format specifier (derived from LOCALE_STIMEFORMAT, use that instead))"" }, | |
{ "LOCALE_ICENTURY", 0x00000024, LR""(DEPRECATED century format specifier (short date, LOCALE_SSHORTDATE is preferred))"" }, | |
{ "LOCALE_ITLZERO", 0x00000025, LR""(DEPRECATED leading zeros in time field (derived from LOCALE_STIMEFORMAT, use that instead))"" }, | |
{ "LOCALE_IDAYLZERO", 0x00000026, LR""(DEPRECATED leading zeros in day field (short date, LOCALE_SSHORTDATE is preferred))"" }, | |
{ "LOCALE_IMONLZERO", 0x00000027, LR""(DEPRECATED leading zeros in month field (short date, LOCALE_SSHORTDATE is preferred))"" }, | |
{ "LOCALE_SAM", 0x00000028, LR""(AM designator, eg "AM")"" }, | |
{ "LOCALE_SPM", 0x00000029, LR""(PM designator, eg "PM")"" }, | |
{ "LOCALE_SDAYNAME1", 0x0000002A, LR""(long name for Monday)"" }, | |
{ "LOCALE_SDAYNAME2", 0x0000002B, LR""(long name for Tuesday)"" }, | |
{ "LOCALE_SDAYNAME3", 0x0000002C, LR""(long name for Wednesday)"" }, | |
{ "LOCALE_SDAYNAME4", 0x0000002D, LR""(long name for Thursday)"" }, | |
{ "LOCALE_SDAYNAME5", 0x0000002E, LR""(long name for Friday)"" }, | |
{ "LOCALE_SDAYNAME6", 0x0000002F, LR""(long name for Saturday)"" }, | |
{ "LOCALE_SDAYNAME7", 0x00000030, LR""(long name for Sunday)"" }, | |
{ "LOCALE_SABBREVDAYNAME1", 0x00000031, LR""(abbreviated name for Monday)"" }, | |
{ "LOCALE_SABBREVDAYNAME2", 0x00000032, LR""(abbreviated name for Tuesday)"" }, | |
{ "LOCALE_SABBREVDAYNAME3", 0x00000033, LR""(abbreviated name for Wednesday)"" }, | |
{ "LOCALE_SABBREVDAYNAME4", 0x00000034, LR""(abbreviated name for Thursday)"" }, | |
{ "LOCALE_SABBREVDAYNAME5", 0x00000035, LR""(abbreviated name for Friday)"" }, | |
{ "LOCALE_SABBREVDAYNAME6", 0x00000036, LR""(abbreviated name for Saturday)"" }, | |
{ "LOCALE_SABBREVDAYNAME7", 0x00000037, LR""(abbreviated name for Sunday)"" }, | |
{ "LOCALE_SMONTHNAME1", 0x00000038, LR""(long name for January)"" }, | |
{ "LOCALE_SMONTHNAME2", 0x00000039, LR""(long name for February)"" }, | |
{ "LOCALE_SMONTHNAME3", 0x0000003A, LR""(long name for March)"" }, | |
{ "LOCALE_SMONTHNAME4", 0x0000003B, LR""(long name for April)"" }, | |
{ "LOCALE_SMONTHNAME5", 0x0000003C, LR""(long name for May)"" }, | |
{ "LOCALE_SMONTHNAME6", 0x0000003D, LR""(long name for June)"" }, | |
{ "LOCALE_SMONTHNAME7", 0x0000003E, LR""(long name for July)"" }, | |
{ "LOCALE_SMONTHNAME8", 0x0000003F, LR""(long name for August)"" }, | |
{ "LOCALE_SMONTHNAME9", 0x00000040, LR""(long name for September)"" }, | |
{ "LOCALE_SMONTHNAME10", 0x00000041, LR""(long name for October)"" }, | |
{ "LOCALE_SMONTHNAME11", 0x00000042, LR""(long name for November)"" }, | |
{ "LOCALE_SMONTHNAME12", 0x00000043, LR""(long name for December)"" }, | |
{ "LOCALE_SABBREVMONTHNAME1", 0x00000044, LR""(abbreviated name for January)"" }, | |
{ "LOCALE_SABBREVMONTHNAME2", 0x00000045, LR""(abbreviated name for February)"" }, | |
{ "LOCALE_SABBREVMONTHNAME3", 0x00000046, LR""(abbreviated name for March)"" }, | |
{ "LOCALE_SABBREVMONTHNAME4", 0x00000047, LR""(abbreviated name for April)"" }, | |
{ "LOCALE_SABBREVMONTHNAME5", 0x00000048, LR""(abbreviated name for May)"" }, | |
{ "LOCALE_SABBREVMONTHNAME6", 0x00000049, LR""(abbreviated name for June)"" }, | |
{ "LOCALE_SABBREVMONTHNAME7", 0x0000004A, LR""(abbreviated name for July)"" }, | |
{ "LOCALE_SABBREVMONTHNAME8", 0x0000004B, LR""(abbreviated name for August)"" }, | |
{ "LOCALE_SABBREVMONTHNAME9", 0x0000004C, LR""(abbreviated name for September)"" }, | |
{ "LOCALE_SABBREVMONTHNAME10", 0x0000004D, LR""(abbreviated name for October)"" }, | |
{ "LOCALE_SABBREVMONTHNAME11", 0x0000004E, LR""(abbreviated name for November)"" }, | |
{ "LOCALE_SABBREVMONTHNAME12", 0x0000004F, LR""(abbreviated name for December)"" }, | |
{ "LOCALE_SPOSITIVESIGN", 0x00000050, LR""(positive sign, eg "")"" }, | |
{ "LOCALE_SNEGATIVESIGN", 0x00000051, LR""(negative sign, eg "-")"" }, | |
{ "LOCALE_IPOSSIGNPOSN", 0x00000052, LR""(positive sign position (derived from INEGCURR))"" }, | |
{ "LOCALE_INEGSIGNPOSN", 0x00000053, LR""(negative sign position (derived from INEGCURR))"" }, | |
{ "LOCALE_IPOSSYMPRECEDES", 0x00000054, LR""(mon sym precedes pos amt (derived from ICURRENCY))"" }, | |
{ "LOCALE_IPOSSEPBYSPACE", 0x00000055, LR""(mon sym sep by space from pos amt (derived from ICURRENCY))"" }, | |
{ "LOCALE_INEGSYMPRECEDES", 0x00000056, LR""(mon sym precedes neg amt (derived from INEGCURR))"" }, | |
{ "LOCALE_INEGSEPBYSPACE", 0x00000057, LR""(mon sym sep by space from neg amt (derived from INEGCURR))"" }, | |
{ "LOCALE_FONTSIGNATURE", 0x00000058, LR""(font signature)"" }, | |
{ "LOCALE_SISO639LANGNAME", 0x00000059, LR""(ISO abbreviated language name, eg "en")"" }, | |
{ "LOCALE_SISO3166CTRYNAME", 0x0000005A, LR""(ISO abbreviated country/region name, eg "US")"" }, | |
{ "LOCALE_IGEOID", 0x0000005B, LR""(DEPRECATED geographical location id, use LOCALE_SISO3166CTRYNAME instead.)"" }, | |
{ "LOCALE_SNAME", 0x0000005c, LR""(locale name (ie: en-us))"" }, | |
{ "LOCALE_SDURATION", 0x0000005d, LR""(time duration format, eg "hh:mm:ss")"" }, | |
{ "LOCALE_SSHORTESTDAYNAME1", 0x00000060, LR""(Shortest day name for Monday)"" }, | |
{ "LOCALE_SSHORTESTDAYNAME2", 0x00000061, LR""(Shortest day name for Tuesday)"" }, | |
{ "LOCALE_SSHORTESTDAYNAME3", 0x00000062, LR""(Shortest day name for Wednesday)"" }, | |
{ "LOCALE_SSHORTESTDAYNAME4", 0x00000063, LR""(Shortest day name for Thursday)"" }, | |
{ "LOCALE_SSHORTESTDAYNAME5", 0x00000064, LR""(Shortest day name for Friday)"" }, | |
{ "LOCALE_SSHORTESTDAYNAME6", 0x00000065, LR""(Shortest day name for Saturday)"" }, | |
{ "LOCALE_SSHORTESTDAYNAME7", 0x00000066, LR""(Shortest day name for Sunday)"" }, | |
{ "LOCALE_SISO639LANGNAME2", 0x00000067, LR""(3 character ISO abbreviated language name, eg "eng")"" }, | |
{ "LOCALE_SISO3166CTRYNAME2", 0x00000068, LR""(3 character ISO country/region name, eg "USA")"" }, | |
{ "LOCALE_SNAN", 0x00000069, LR""(Not a Number, eg "NaN")"" }, | |
{ "LOCALE_SPOSINFINITY", 0x0000006a, LR""(+ Infinity, eg "infinity")"" }, | |
{ "LOCALE_SNEGINFINITY", 0x0000006b, LR""(- Infinity, eg "-infinity")"" }, | |
{ "LOCALE_SSCRIPTS", 0x0000006c, LR""(Typical scripts in the locale: ; delimited script codes, eg "Latn;")"" }, | |
{ "LOCALE_SPARENT", 0x0000006d, LR""(Fallback name for resources, eg "en" for "en-US")"" }, | |
{ "LOCALE_SCONSOLEFALLBACKNAME", 0x0000006e, LR""(Fallback name for within the console for Unicode Only locales, eg "en" for bn-IN)"" }, | |
{ "LOCALE_SLOCALIZEDLANGUAGENAME", 0x0000006f, LR""(Language Display Name for a language, eg "German" in UI language)"" }, | |
{ "LOCALE_IREADINGLAYOUT", 0x00000070, LR""(Returns one of the following 4 reading layout values: | |
0 - Left to right (eg en-US) | |
1 - Right to left (eg arabic locales) | |
2 - Vertical top to bottom with columns to the left and also left to right (ja-JP locales) | |
3 - Vertical top to bottom with columns proceeding to the right)"" }, | |
{ "LOCALE_INEUTRAL", 0x00000071, LR""(Returns 0 for specific cultures, 1 for neutral cultures.)"" }, | |
{ "LOCALE_SENGLISHDISPLAYNAME", 0x00000072, LR""(Display name (language + country/region usually) in English, eg "German (Germany)")"" }, | |
{ "LOCALE_SNATIVEDISPLAYNAME", 0x00000073, LR""(Display name in native locale language, eg "Deutsch (Deutschland))"" }, | |
{ "LOCALE_INEGATIVEPERCENT", 0x00000074, LR""(Returns 0-11 for the negative percent format)"" }, | |
{ "LOCALE_IPOSITIVEPERCENT", 0x00000075, LR""(Returns 0-3 for the positive percent formatIPOSITIVEPERCENT)"" }, | |
{ "LOCALE_SPERCENT", 0x00000076, LR""(Returns the percent symbol)"" }, | |
{ "LOCALE_SPERMILLE", 0x00000077, LR""(Returns the permille (U+2030) symbol)"" }, | |
{ "LOCALE_SMONTHDAY", 0x00000078, LR""(Returns the preferred month/day format)"" }, | |
{ "LOCALE_SSHORTTIME", 0x00000079, LR""(Returns the preferred short time format (ie: no seconds, just h:mm))"" }, | |
{ "LOCALE_SOPENTYPELANGUAGETAG", 0x0000007a, LR""(Open type language tag, eg: "latn" or "dflt")"" }, | |
{ "LOCALE_SSORTLOCALE", 0x0000007b, LR""(Name of locale to use for sorting/collation/casing behavior.)"" }, | |
{ "LOCALE_SRELATIVELONGDATE", 0x0000007c, LR""(Long date without year, day of week, month, date, eg: for lock screen)"" }, | |
{ "LOCALE_SSHORTESTAM", 0x0000007e, LR""(Shortest AM designator, eg "A")"" }, | |
{ "LOCALE_SSHORTESTPM", 0x0000007f, LR""(Shortest PM designator, eg "P")"" }, | |
{ "LOCALE_SENGLISHLANGUAGENAME", 0x00001001, LR""(English name of language, eg "German")"" }, | |
{ "LOCALE_SENGLISHCOUNTRYNAME", 0x00001002, LR""(English name of country/region, eg "Germany")"" }, | |
{ "LOCALE_STIMEFORMAT", 0x00001003, LR""(time format string, eg "HH:mm:ss")"" }, | |
{ "LOCALE_IDEFAULTANSICODEPAGE", 0x00001004, LR""(default ansi code page for locale (user may configure as UTF-8, use of Unicode is recommended instead))"" }, | |
{ "LOCALE_ITIMEMARKPOSN", 0x00001005, LR""(DEPRECATED time marker position (derived from LOCALE_STIMEFORMAT, use that instead))"" }, | |
{ "LOCALE_SYEARMONTH", 0x00001006, LR""(year month format string, eg "MM/yyyy")"" }, | |
{ "LOCALE_SENGCURRNAME", 0x00001007, LR""(english name of currency, eg "Euro")"" }, | |
{ "LOCALE_SNATIVECURRNAME", 0x00001008, LR""(native name of currency, eg "euro")"" }, | |
{ "LOCALE_ICALENDARTYPE", 0x00001009, LR""(type of calendar specifier, eg CAL_GREGORIAN)"" }, | |
{ "LOCALE_IPAPERSIZE", 0x0000100A, LR""(1 = letter, 5 = legal, 8 = a3, 9 = a4)"" }, | |
{ "LOCALE_IOPTIONALCALENDAR", 0x0000100B, LR""(additional calendar types specifier, eg CAL_GREGORIAN_US)"" }, | |
{ "LOCALE_IFIRSTDAYOFWEEK", 0x0000100C, LR""(first day of week specifier, 0-6, 0=Monday, 6=Sunday)"" }, | |
{ "LOCALE_IFIRSTWEEKOFYEAR", 0x0000100D, LR""(first week of year specifier, 0-2, see documentation)"" }, | |
{ "LOCALE_SMONTHNAME13", 0x0000100E, LR""(long name for 13th month (if exists))"" }, | |
{ "LOCALE_SABBREVMONTHNAME13", 0x0000100F, LR""(abbreviated name for 13th month (if exists))"" }, | |
{ "LOCALE_INEGNUMBER", 0x00001010, LR""(negative number mode, 0-4, see documentation)"" }, | |
{ "LOCALE_IDEFAULTMACCODEPAGE", 0x00001011, LR""(default mac code page for locale (user may configure as UTF-8, use of Unicode is recommended instead))"" }, | |
{ "LOCALE_IDEFAULTEBCDICCODEPAGE", 0x00001012, LR""(default ebcdic code page for a locale (use of Unicode is recommended instead))"" }, | |
{ "LOCALE_SSORTNAME", 0x00001013, LR""(sort name, usually "", eg "Dictionary" in UI Language)"" }, | |
{ "LOCALE_IDIGITSUBSTITUTION", 0x00001014, LR""(0 = context, 1 = none, 2 = national)"" }, | |
}; | |
int main(int argc, char* argv[]) | |
{ | |
if (argc != 2) { | |
fwprintf(stderr, L"Usage: %hs <LOCALE_XXX>|all\n", argv[0]); | |
return 2; | |
} | |
auto const arg = argv[1]; | |
if (strcmp(arg, "all") == 0) { | |
for (auto const& opt: localeOptions) { | |
wprintf(L"% 32hs = %ls\n", opt.name, opt.GetValue()); | |
} | |
} else { | |
for (auto const& opt: localeOptions) { | |
if (strcmp(opt.name, arg) == 0) { | |
wprintf(L"%hs = %ls\n", opt.name, opt.GetValue()); | |
return 0; | |
} | |
} | |
fwprintf(stderr, L"Unknown option \"%hs\".\n", arg); | |
return 2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment