20#pragma GCC diagnostic push
21#pragma GCC diagnostic ignored "-Wexit-time-destructors"
27 using langid = LANGID;
29 using langid = uint16_t;
32 constexpr langid langid_neutral = 0x0;
33 constexpr langid langid_unknown = 0x7f;
34 constexpr langid langid_system = 0x800;
36 constexpr langid sublangid_neutral = 0 << 10;
37 constexpr langid sublangid_default = 1 << 10;
38 constexpr langid sublangid_sys_default = 2 << 10;
39 constexpr langid sublangid_custom_default = 3 << 10;
40 constexpr langid sublangid_custom_unspecified = 4 << 10;
41 constexpr langid sublangid_ui_custom_default = 5 << 10;
50 inline constexpr langid primary_langid(_In_ langid lang)
62 inline constexpr langid sub_langid(_In_ langid lang)
74 inline langid langid_from_rfc1766(_In_z_
const char* rfc1766)
78 bool operator()(_In_z_
const char* str1, _In_z_
const char* str2)
const
84 auto a = stdex::tolower(str1[i]);
85 auto b = stdex::tolower(str2[i]);
86 if (!a && !b)
return false;
89 auto a_punct = stdex::ispunct(a);
90 auto b_punct = stdex::ispunct(b);
91 if (a_punct && b_punct)
continue;
92 if (b_punct)
return false;
93 if (a_punct)
return true;
94 if (a > b)
return false;
95 if (a < b)
return true;
99 static const std::map<const char*, int, stricmp_less> languages = {
125 {
"az-Cyrl-AZ", 0x742c},
126 {
"az-Cyrl-AZ", 0x82c},
127 {
"az-Latn-AZ", 0x42c},
128 {
"az-Latn-AZ", 0x782c},
145 {
"bs-Cyrl-BA", 0x201a},
146 {
"bs-Cyrl-BA", 0x641a},
147 {
"bs-Latn-BA", 0x141a},
148 {
"bs-Latn-BA", 0x681a},
149 {
"bs-Latn-BA", 0x781a},
150 {
"ca-ES-valencia", 0x803},
153 {
"chr-Cher-US", 0x45c},
154 {
"chr-Cher-US", 0x7c5c},
206 {
"es-ES_tradnl", 0x40a},
229 {
"ff-Latn-NG", 0x467},
230 {
"ff-Latn-SN", 0x7c67},
231 {
"ff-Latn-SN", 0x867},
269 {
"ha-Latn-NG", 0x468},
270 {
"ha-Latn-NG", 0x7c68},
300 {
"iu-Cans-CA", 0x45d},
301 {
"iu-Cans-CA", 0x785d},
302 {
"iu-Latn-CA", 0x7c5d},
303 {
"iu-Latn-CA", 0x85d},
321 {
"kr-Latn-NG", 0x471},
323 {
"ks-Arab-IN", 0x460},
324 {
"ks-Deva-IN", 0x860},
326 {
"ku-Arab-IQ", 0x492},
327 {
"ku-Arab-IQ", 0x7c92},
349 {
"mn-Mong-CN", 0x7c50},
350 {
"mn-Mong-CN", 0x850},
351 {
"mn-Mong-MN", 0xc50},
385 {
"pa-Arab-PK", 0x7c46},
386 {
"pa-Arab-PK", 0x846},
398 {
"qps-Latn-x-sh", 0x901},
400 {
"qps-ploca", 0x5fe},
401 {
"qps-plocm", 0x9ff},
402 {
"quc-Latn-GT", 0x486},
403 {
"quc-Latn-GT", 0x7c86},
423 {
"sd-Arab-PK", 0x7c59},
424 {
"sd-Arab-PK", 0x859},
425 {
"sd-Deva-IN", 0x459},
451 {
"sr-Cyrl-BA", 0x1c1a},
452 {
"sr-Cyrl-CS", 0xc1a},
453 {
"sr-Cyrl-ME", 0x301a},
454 {
"sr-Cyrl-RS", 0x281a},
455 {
"sr-Cyrl-RS", 0x6c1a},
456 {
"sr-Latn-BA", 0x181a},
457 {
"sr-Latn-CS", 0x81a},
458 {
"sr-Latn-ME", 0x2c1a},
459 {
"sr-Latn-RS", 0x241a},
460 {
"sr-Latn-RS", 0x701a},
461 {
"sr-Latn-RS", 0x7c1a},
476 {
"tg-Cyrl-TJ", 0x428},
477 {
"tg-Cyrl-TJ", 0x7c28},
495 {
"tzm-Arab-MA", 0x45f},
496 {
"tzm-Latn-DZ", 0x7c5f},
497 {
"tzm-Latn-DZ", 0x85f},
498 {
"tzm-Tfng-MA", 0x105f},
499 {
"tzm-Tfng-MA", 0x785f},
508 {
"uz-Cyrl-UZ", 0x7843},
509 {
"uz-Cyrl-UZ", 0x843},
510 {
"uz-Latn-UZ", 0x443},
511 {
"uz-Latn-UZ", 0x7c43},
536 if (
auto el = languages.find(rfc1766); el != languages.end())
537 return static_cast<langid
>(el->second);
538 return langid_unknown;
549 inline _Ret_maybenull_z_
const char* rfc1766_from_langid(_In_ langid lang, _In_opt_z_
const char* fallback =
nullptr)
551 static const std::map<int, const char*> languages = {
573 {0x803,
"ca-ES-valencia"},
615 {0x40a,
"es-ES_tradnl"},
692 {0x81a,
"sr-Latn-CS"},
693 {0xc1a,
"sr-Cyrl-CS"},
695 {0x141a,
"bs-Latn-BA"},
696 {0x181a,
"sr-Latn-BA"},
697 {0x1c1a,
"sr-Cyrl-BA"},
698 {0x201a,
"bs-Cyrl-BA"},
699 {0x241a,
"sr-Latn-RS"},
700 {0x281a,
"sr-Cyrl-RS"},
701 {0x2c1a,
"sr-Latn-ME"},
702 {0x301a,
"sr-Cyrl-ME"},
703 {0x641a,
"bs-Cyrl-BA"},
704 {0x681a,
"bs-Latn-BA"},
705 {0x6c1a,
"sr-Cyrl-RS"},
706 {0x701a,
"sr-Latn-RS"},
707 {0x781a,
"bs-Latn-BA"},
708 {0x7c1a,
"sr-Latn-RS"},
738 {0x428,
"tg-Cyrl-TJ"},
739 {0x7c28,
"tg-Cyrl-TJ"},
747 {0x42c,
"az-Latn-AZ"},
748 {0x82c,
"az-Cyrl-AZ"},
749 {0x742c,
"az-Cyrl-AZ"},
750 {0x782c,
"az-Latn-AZ"},
812 {0x443,
"uz-Latn-UZ"},
813 {0x843,
"uz-Cyrl-UZ"},
814 {0x7843,
"uz-Cyrl-UZ"},
815 {0x7c43,
"uz-Latn-UZ"},
823 {0x846,
"pa-Arab-PK"},
824 {0x7c46,
"pa-Arab-PK"},
846 {0x850,
"mn-Mong-CN"},
847 {0xc50,
"mn-Mong-MN"},
849 {0x7c50,
"mn-Mong-CN"},
868 {0x459,
"sd-Deva-IN"},
869 {0x859,
"sd-Arab-PK"},
870 {0x7c59,
"sd-Arab-PK"},
876 {0x45c,
"chr-Cher-US"},
877 {0x7c5c,
"chr-Cher-US"},
879 {0x45d,
"iu-Cans-CA"},
880 {0x85d,
"iu-Latn-CA"},
881 {0x785d,
"iu-Cans-CA"},
882 {0x7c5d,
"iu-Latn-CA"},
886 {0x45f,
"tzm-Arab-MA"},
887 {0x85f,
"tzm-Latn-DZ"},
888 {0x105f,
"tzm-Tfng-MA"},
889 {0x785f,
"tzm-Tfng-MA"},
890 {0x7c5f,
"tzm-Latn-DZ"},
892 {0x460,
"ks-Arab-IN"},
893 {0x860,
"ks-Deva-IN"},
908 {0x467,
"ff-Latn-NG"},
909 {0x867,
"ff-Latn-SN"},
910 {0x7c67,
"ff-Latn-SN"},
912 {0x468,
"ha-Latn-NG"},
913 {0x7c68,
"ha-Latn-NG"},
933 {0x471,
"kr-Latn-NG"},
970 {0x486,
"quc-Latn-GT"},
971 {0x7c86,
"quc-Latn-GT"},
981 {0x492,
"ku-Arab-IQ"},
982 {0x7c92,
"ku-Arab-IQ"},
984 {0x901,
"qps-Latn-x-sh"},
985 {0x5fe,
"qps-ploca"},
986 {0x9ff,
"qps-plocm"},
988 if (
auto el = languages.find(lang); el != languages.end())
995#pragma GCC diagnostic pop