📄 localename.c
字号:
# endif# ifndef SUBLANG_CHINESE_MACAU# define SUBLANG_CHINESE_MACAU 0x05# endif# ifndef SUBLANG_ENGLISH_SOUTH_AFRICA# define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07# endif# ifndef SUBLANG_ENGLISH_JAMAICA# define SUBLANG_ENGLISH_JAMAICA 0x08# endif# ifndef SUBLANG_ENGLISH_CARIBBEAN# define SUBLANG_ENGLISH_CARIBBEAN 0x09# endif# ifndef SUBLANG_ENGLISH_BELIZE# define SUBLANG_ENGLISH_BELIZE 0x0a# endif# ifndef SUBLANG_ENGLISH_TRINIDAD# define SUBLANG_ENGLISH_TRINIDAD 0x0b# endif# ifndef SUBLANG_ENGLISH_ZIMBABWE# define SUBLANG_ENGLISH_ZIMBABWE 0x0c# endif# ifndef SUBLANG_ENGLISH_PHILIPPINES# define SUBLANG_ENGLISH_PHILIPPINES 0x0d# endif# ifndef SUBLANG_ENGLISH_INDONESIA# define SUBLANG_ENGLISH_INDONESIA 0x0e# endif# ifndef SUBLANG_ENGLISH_HONGKONG# define SUBLANG_ENGLISH_HONGKONG 0x0f# endif# ifndef SUBLANG_ENGLISH_INDIA# define SUBLANG_ENGLISH_INDIA 0x10# endif# ifndef SUBLANG_ENGLISH_MALAYSIA# define SUBLANG_ENGLISH_MALAYSIA 0x11# endif# ifndef SUBLANG_ENGLISH_SINGAPORE# define SUBLANG_ENGLISH_SINGAPORE 0x12# endif# ifndef SUBLANG_FRENCH_LUXEMBOURG# define SUBLANG_FRENCH_LUXEMBOURG 0x05# endif# ifndef SUBLANG_FRENCH_MONACO# define SUBLANG_FRENCH_MONACO 0x06# endif# ifndef SUBLANG_FRENCH_WESTINDIES# define SUBLANG_FRENCH_WESTINDIES 0x07# endif# ifndef SUBLANG_FRENCH_REUNION# define SUBLANG_FRENCH_REUNION 0x08# endif# ifndef SUBLANG_FRENCH_CONGO# define SUBLANG_FRENCH_CONGO 0x09# endif# ifndef SUBLANG_FRENCH_SENEGAL# define SUBLANG_FRENCH_SENEGAL 0x0a# endif# ifndef SUBLANG_FRENCH_CAMEROON# define SUBLANG_FRENCH_CAMEROON 0x0b# endif# ifndef SUBLANG_FRENCH_COTEDIVOIRE# define SUBLANG_FRENCH_COTEDIVOIRE 0x0c# endif# ifndef SUBLANG_FRENCH_MALI# define SUBLANG_FRENCH_MALI 0x0d# endif# ifndef SUBLANG_FRENCH_MOROCCO# define SUBLANG_FRENCH_MOROCCO 0x0e# endif# ifndef SUBLANG_FRENCH_HAITI# define SUBLANG_FRENCH_HAITI 0x0f# endif# ifndef SUBLANG_GERMAN_LUXEMBOURG# define SUBLANG_GERMAN_LUXEMBOURG 0x04# endif# ifndef SUBLANG_GERMAN_LIECHTENSTEIN# define SUBLANG_GERMAN_LIECHTENSTEIN 0x05# endif# ifndef SUBLANG_KASHMIRI_INDIA# define SUBLANG_KASHMIRI_INDIA 0x02# endif# ifndef SUBLANG_MALAY_MALAYSIA# define SUBLANG_MALAY_MALAYSIA 0x01# endif# ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM# define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02# endif# ifndef SUBLANG_NEPALI_INDIA# define SUBLANG_NEPALI_INDIA 0x02# endif# ifndef SUBLANG_PUNJABI_INDIA# define SUBLANG_PUNJABI_INDIA 0x00# endif# ifndef SUBLANG_PUNJABI_PAKISTAN# define SUBLANG_PUNJABI_PAKISTAN 0x01# endif# ifndef SUBLANG_ROMANIAN_ROMANIA# define SUBLANG_ROMANIAN_ROMANIA 0x00# endif# ifndef SUBLANG_ROMANIAN_MOLDOVA# define SUBLANG_ROMANIAN_MOLDOVA 0x01# endif# ifndef SUBLANG_SERBIAN_LATIN# define SUBLANG_SERBIAN_LATIN 0x02# endif# ifndef SUBLANG_SERBIAN_CYRILLIC# define SUBLANG_SERBIAN_CYRILLIC 0x03# endif# ifndef SUBLANG_SINDHI_INDIA# define SUBLANG_SINDHI_INDIA 0x00# endif# ifndef SUBLANG_SINDHI_PAKISTAN# define SUBLANG_SINDHI_PAKISTAN 0x01# endif# ifndef SUBLANG_SPANISH_GUATEMALA# define SUBLANG_SPANISH_GUATEMALA 0x04# endif# ifndef SUBLANG_SPANISH_COSTA_RICA# define SUBLANG_SPANISH_COSTA_RICA 0x05# endif# ifndef SUBLANG_SPANISH_PANAMA# define SUBLANG_SPANISH_PANAMA 0x06# endif# ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC# define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07# endif# ifndef SUBLANG_SPANISH_VENEZUELA# define SUBLANG_SPANISH_VENEZUELA 0x08# endif# ifndef SUBLANG_SPANISH_COLOMBIA# define SUBLANG_SPANISH_COLOMBIA 0x09# endif# ifndef SUBLANG_SPANISH_PERU# define SUBLANG_SPANISH_PERU 0x0a# endif# ifndef SUBLANG_SPANISH_ARGENTINA# define SUBLANG_SPANISH_ARGENTINA 0x0b# endif# ifndef SUBLANG_SPANISH_ECUADOR# define SUBLANG_SPANISH_ECUADOR 0x0c# endif# ifndef SUBLANG_SPANISH_CHILE# define SUBLANG_SPANISH_CHILE 0x0d# endif# ifndef SUBLANG_SPANISH_URUGUAY# define SUBLANG_SPANISH_URUGUAY 0x0e# endif# ifndef SUBLANG_SPANISH_PARAGUAY# define SUBLANG_SPANISH_PARAGUAY 0x0f# endif# ifndef SUBLANG_SPANISH_BOLIVIA# define SUBLANG_SPANISH_BOLIVIA 0x10# endif# ifndef SUBLANG_SPANISH_EL_SALVADOR# define SUBLANG_SPANISH_EL_SALVADOR 0x11# endif# ifndef SUBLANG_SPANISH_HONDURAS# define SUBLANG_SPANISH_HONDURAS 0x12# endif# ifndef SUBLANG_SPANISH_NICARAGUA# define SUBLANG_SPANISH_NICARAGUA 0x13# endif# ifndef SUBLANG_SPANISH_PUERTO_RICO# define SUBLANG_SPANISH_PUERTO_RICO 0x14# endif# ifndef SUBLANG_SWEDISH_FINLAND# define SUBLANG_SWEDISH_FINLAND 0x02# endif# ifndef SUBLANG_TAMAZIGHT_ARABIC# define SUBLANG_TAMAZIGHT_ARABIC 0x01# endif# ifndef SUBLANG_TAMAZIGHT_LATIN# define SUBLANG_TAMAZIGHT_LATIN 0x02# endif# ifndef SUBLANG_TIGRINYA_ETHIOPIA# define SUBLANG_TIGRINYA_ETHIOPIA 0x00# endif# ifndef SUBLANG_TIGRINYA_ERITREA# define SUBLANG_TIGRINYA_ERITREA 0x01# endif# ifndef SUBLANG_URDU_PAKISTAN# define SUBLANG_URDU_PAKISTAN 0x01# endif# ifndef SUBLANG_URDU_INDIA# define SUBLANG_URDU_INDIA 0x02# endif# ifndef SUBLANG_UZBEK_LATIN# define SUBLANG_UZBEK_LATIN 0x01# endif# ifndef SUBLANG_UZBEK_CYRILLIC# define SUBLANG_UZBEK_CYRILLIC 0x02# endif#endif# if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE/* MacOS X 10.2 or newer *//* Canonicalize a MacOS X locale name to a Unix locale name. NAME is a sufficiently large buffer. On input, it contains the MacOS X locale name. On output, it contains the Unix locale name. */void_nl_locale_name_canonicalize (char *name){ /* This conversion is based on a posting by Deborah GoldSmith <goldsmit@apple.com> on 2005-03-08, http://lists.apple.com/archives/carbon-dev/2005/Mar/msg00293.html */ /* Convert legacy (NeXTstep inherited) English names to Unix (ISO 639 and ISO 3166) names. Prior to MacOS X 10.3, there is no API for doing this. Therefore we do it ourselves, using a table based on the results of the MacOS X 10.3.8 function CFLocaleCreateCanonicalLocaleIdentifierFromString(). */ typedef struct { const char legacy[21+1]; const char unixy[5+1]; } legacy_entry; static const legacy_entry legacy_table[] = { { "Afrikaans", "af" }, { "Albanian", "sq" }, { "Amharic", "am" }, { "Arabic", "ar" }, { "Armenian", "hy" }, { "Assamese", "as" }, { "Aymara", "ay" }, { "Azerbaijani", "az" }, { "Basque", "eu" }, { "Belarusian", "be" }, { "Belorussian", "be" }, { "Bengali", "bn" }, { "Brazilian Portugese", "pt_BR" }, { "Brazilian Portuguese", "pt_BR" }, { "Breton", "br" }, { "Bulgarian", "bg" }, { "Burmese", "my" }, { "Byelorussian", "be" }, { "Catalan", "ca" }, { "Chewa", "ny" }, { "Chichewa", "ny" }, { "Chinese", "zh" }, { "Chinese, Simplified", "zh_CN" }, { "Chinese, Traditional", "zh_TW" }, { "Chinese, Tradtional", "zh_TW" }, { "Croatian", "hr" }, { "Czech", "cs" }, { "Danish", "da" }, { "Dutch", "nl" }, { "Dzongkha", "dz" }, { "English", "en" }, { "Esperanto", "eo" }, { "Estonian", "et" }, { "Faroese", "fo" }, { "Farsi", "fa" }, { "Finnish", "fi" }, { "Flemish", "nl_BE" }, { "French", "fr" }, { "Galician", "gl" }, { "Gallegan", "gl" }, { "Georgian", "ka" }, { "German", "de" }, { "Greek", "el" }, { "Greenlandic", "kl" }, { "Guarani", "gn" }, { "Gujarati", "gu" }, { "Hawaiian", "haw" }, /* Yes, "haw", not "cpe". */ { "Hebrew", "he" }, { "Hindi", "hi" }, { "Hungarian", "hu" }, { "Icelandic", "is" }, { "Indonesian", "id" }, { "Inuktitut", "iu" }, { "Irish", "ga" }, { "Italian", "it" }, { "Japanese", "ja" }, { "Javanese", "jv" }, { "Kalaallisut", "kl" }, { "Kannada", "kn" }, { "Kashmiri", "ks" }, { "Kazakh", "kk" }, { "Khmer", "km" }, { "Kinyarwanda", "rw" }, { "Kirghiz", "ky" }, { "Korean", "ko" }, { "Kurdish", "ku" }, { "Latin", "la" }, { "Latvian", "lv" }, { "Lithuanian", "lt" }, { "Macedonian", "mk" }, { "Malagasy", "mg" }, { "Malay", "ms" }, { "Malayalam", "ml" }, { "Maltese", "mt" }, { "Manx", "gv" }, { "Marathi", "mr" }, { "Moldavian", "mo" }, { "Mongolian", "mn" }, { "Nepali", "ne" }, { "Norwegian", "nb" }, /* Yes, "nb", not the obsolete "no". */ { "Nyanja", "ny" }, { "Nynorsk", "nn" }, { "Oriya", "or" }, { "Oromo", "om" }, { "Panjabi", "pa" }, { "Pashto", "ps" }, { "Persian", "fa" }, { "Polish", "pl" }, { "Portuguese", "pt" }, { "Portuguese, Brazilian", "pt_BR" }, { "Punjabi", "pa" }, { "Pushto", "ps" }, { "Quechua", "qu" }, { "Romanian", "ro" }, { "Ruanda", "rw" }, { "Rundi", "rn" }, { "Russian", "ru" }, { "Sami", "se_NO" }, /* Not just "se". */ { "Sanskrit", "sa" }, { "Scottish", "gd" }, { "Serbian", "sr" }, { "Simplified Chinese", "zh_CN" }, { "Sindhi", "sd" }, { "Sinhalese", "si" }, { "Slovak", "sk" }, { "Slovenian", "sl" }, { "Somali", "so" }, { "Spanish", "es" }, { "Sundanese", "su" }, { "Swahili", "sw" }, { "Swedish", "sv" }, { "Tagalog", "tl" }, { "Tajik", "tg" }, { "Tajiki", "tg" }, { "Tamil", "ta" }, { "Tatar", "tt" }, { "Telugu", "te" }, { "Thai", "th" }, { "Tibetan", "bo" }, { "Tigrinya", "ti" }, { "Tongan", "to" }, { "Traditional Chinese", "zh_TW" }, { "Turkish", "tr" }, { "Turkmen", "tk" }, { "Uighur", "ug" }, { "Ukrainian", "uk" }, { "Urdu", "ur" }, { "Uzbek", "uz" }, { "Vietnamese", "vi" }, { "Welsh", "cy" }, { "Yiddish", "yi" } }; /* Convert new-style locale names with language tags (ISO 639 and ISO 15924) to Unix (ISO 639 and ISO 3166) names. */ typedef struct { const char langtag[7+1]; const char unixy[12+1]; } langtag_entry; static const langtag_entry langtag_table[] = { /* MacOS X has "az-Arab", "az-Cyrl", "az-Latn". The default script for az on Unix is Latin. */ { "az-Latn", "az" }, /* MacOS X has "ga-dots". Does not yet exist on Unix. */ { "ga-dots", "ga" }, /* MacOS X has "kk-Cyrl". Does not yet exist on Unix. */ /* MacOS X has "mn-Cyrl", "mn-Mong". The default script for mn on Unix is Cyrillic. */ { "mn-Cyrl", "mn" }, /* MacOS X has "ms-Arab", "ms-Latn". The default script for ms on Unix is Latin. */ { "ms-Latn", "ms" }, /* MacOS X has "tg-Cyrl". The default script for tg on Unix is Cyrillic. */ { "tg-Cyrl", "tg" }, /* MacOS X has "tk-Cyrl". Does not yet exist on Unix. */ /* MacOS X has "tt-Cyrl". The default script for tt on Unix is Cyrillic. */ { "tt-Cyrl", "tt" }, /* MacOS X has "zh-Hans", "zh-Hant". Country codes are used to distinguish these on Unix. */ { "zh-Hans", "zh_CN" }, { "zh-Hant", "zh_TW" } }; /* Convert script names (ISO 15924) to Unix conventions. See http://www.unicode.org/iso15924/iso15924-codes.html */ typedef struct { const char script[4+1]; const char unixy[9+1]; } script_entry; static const script_entry script_table[] = { { "Arab", "arabic" }, { "Cyrl", "cyrillic" }, { "Mong", "mongolian" } }; /* Step 1: Convert using legacy_table. */ if (name[0] >= 'A' && name[0] <= 'Z') { unsigned int i1, i2; i1 = 0; i2 = sizeof (legacy_table) / sizeof (legacy_entry); while (i2 - i1 > 1) { /* At this point we know that if name occurs in legacy_table, its index must be >= i1 and < i2. */ unsigned int i = (i1 + i2) >> 1; const legacy_entry *p = &legacy_table[i]; if (strcmp (name, p->legacy) < 0) i2 = i; else i1 = i; } if (strcmp (name, legacy_table[i1].legacy) == 0) { strcpy (name, legacy_table[i1].unixy); return; } } /* Step 2: Convert using langtag_table and script_table. */ if (strlen (name) == 7 && name[2] == '-') { unsigned int i1, i2; i1 = 0; i2 = sizeof (langtag_table) / sizeof (langtag_entry); while (i2 - i1 > 1) { /* At this point we know that if name occurs in langtag_table, its index must be >= i1 and < i2. */ unsigned int i = (i1 + i2) >> 1; const langtag_entry *p = &langtag_table[i]; if (strcmp (name, p->langtag) < 0) i2 = i; else i1 = i; } if (strcmp (name, langtag_table[i1].langtag) == 0) { strcpy (name, langtag_table[i1].unixy); return; } i1 = 0; i2 = sizeof (script_table) / sizeof (script_entry); while (i2 - i1 > 1) { /* At this point we know that if (name + 3) occurs in script_table, its index must be >= i1 and < i2. */ unsigned int i = (i1 + i2) >> 1; const script_entry *p = &script_table[i]; if (strcmp (name + 3, p->script) < 0) i2 = i; else i1 = i; } if (strcmp (name + 3, script_table[i1].script) == 0) { name[2] = '@'; strcpy (name + 3, script_table[i1].unixy); return; } } /* Step 3: Convert new-style dash to Unix underscore. */ { char *p; for (p = name; *p != '\0'; p++) if (*p == '-') *p = '_'; }}#endif/* XPG3 defines the result of 'setlocale (category, NULL)' as: "Directs 'setlocale()' to query 'category' and return the current setting of 'local'." However it does not specify the exact format. Neither do SUSV2 and ISO C 99. So we can use this feature only on selected systems (e.g. those using GNU C Library). */#if defined _LIBC || (defined __GLIBC__ && __GLIBC__ >= 2)# define HAVE_LOCALE_NULL#endif/* Determine the current locale's name, and canonicalize it into XPG syntax language[_territory][.codeset][@modifier] The codeset part in the result is not reliable; the locale_charset() should be used for codeset information instead. The result must not be freed; it is statically allocated. */const char *_nl_locale_name_posix (int category, const char *categoryname){ /* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'. On some systems this can be done by the 'setlocale' function itself. */#if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL return setlocale (category, NULL);#else const char *retval; /* Setting of LC_ALL overrides all other. */ retval = getenv ("LC_ALL"); if (retval != NULL && retval[0] != '\0') return retval; /* Next comes the name of the desired category. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -