Back to index

courier  0.68.2
localename.c
Go to the documentation of this file.
00001 /* Determine name of the currently selected locale.
00002    Copyright (C) 1995-1999, 2000-2010 Free Software Foundation, Inc.
00003 
00004    This program is free software; you can redistribute it and/or modify it
00005    under the terms of the GNU Library General Public License as published
00006    by the Free Software Foundation; either version 2, or (at your option)
00007    any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public
00015    License along with this program; if not, write to the Free Software
00016    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00017    USA.  */
00018 
00019 /* Written by Ulrich Drepper <drepper@gnu.org>, 1995.  */
00020 /* Win32 code written by Tor Lillqvist <tml@iki.fi>.  */
00021 /* MacOS X code written by Bruno Haible <bruno@clisp.org>.  */
00022 
00023 #include <config.h>
00024 
00025 /* Specification.  */
00026 #ifdef IN_LIBINTL
00027 # include "gettextP.h"
00028 #else
00029 # include "localename.h"
00030 #endif
00031 
00032 #include <limits.h>
00033 #include <stddef.h>
00034 #include <stdlib.h>
00035 #include <locale.h>
00036 #include <string.h>
00037 
00038 #if HAVE_USELOCALE
00039 /* MacOS X 10.5 defines the locale_t type in <xlocale.h>.  */
00040 # if defined __APPLE__ && defined __MACH__
00041 #  include <xlocale.h>
00042 # endif
00043 # include <langinfo.h>
00044 # if !defined IN_LIBINTL
00045 #  include "glthread/lock.h"
00046 # endif
00047 #endif
00048 
00049 #if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
00050 # include <CoreFoundation/CFString.h>
00051 # if HAVE_CFLOCALECOPYCURRENT
00052 #  include <CoreFoundation/CFLocale.h>
00053 # elif HAVE_CFPREFERENCESCOPYAPPVALUE
00054 #  include <CoreFoundation/CFPreferences.h>
00055 # endif
00056 #endif
00057 
00058 #if defined _WIN32 || defined __WIN32__
00059 # define WIN32_NATIVE
00060 #endif
00061 
00062 #if defined WIN32_NATIVE || defined __CYGWIN__ /* WIN32 or Cygwin */
00063 # define WIN32_LEAN_AND_MEAN
00064 # include <windows.h>
00065 /* List of language codes, sorted by value:
00066    0x01 LANG_ARABIC
00067    0x02 LANG_BULGARIAN
00068    0x03 LANG_CATALAN
00069    0x04 LANG_CHINESE
00070    0x05 LANG_CZECH
00071    0x06 LANG_DANISH
00072    0x07 LANG_GERMAN
00073    0x08 LANG_GREEK
00074    0x09 LANG_ENGLISH
00075    0x0a LANG_SPANISH
00076    0x0b LANG_FINNISH
00077    0x0c LANG_FRENCH
00078    0x0d LANG_HEBREW
00079    0x0e LANG_HUNGARIAN
00080    0x0f LANG_ICELANDIC
00081    0x10 LANG_ITALIAN
00082    0x11 LANG_JAPANESE
00083    0x12 LANG_KOREAN
00084    0x13 LANG_DUTCH
00085    0x14 LANG_NORWEGIAN
00086    0x15 LANG_POLISH
00087    0x16 LANG_PORTUGUESE
00088    0x17 LANG_ROMANSH
00089    0x18 LANG_ROMANIAN
00090    0x19 LANG_RUSSIAN
00091    0x1a LANG_CROATIAN == LANG_SERBIAN
00092    0x1b LANG_SLOVAK
00093    0x1c LANG_ALBANIAN
00094    0x1d LANG_SWEDISH
00095    0x1e LANG_THAI
00096    0x1f LANG_TURKISH
00097    0x20 LANG_URDU
00098    0x21 LANG_INDONESIAN
00099    0x22 LANG_UKRAINIAN
00100    0x23 LANG_BELARUSIAN
00101    0x24 LANG_SLOVENIAN
00102    0x25 LANG_ESTONIAN
00103    0x26 LANG_LATVIAN
00104    0x27 LANG_LITHUANIAN
00105    0x28 LANG_TAJIK
00106    0x29 LANG_FARSI
00107    0x2a LANG_VIETNAMESE
00108    0x2b LANG_ARMENIAN
00109    0x2c LANG_AZERI
00110    0x2d LANG_BASQUE
00111    0x2e LANG_SORBIAN
00112    0x2f LANG_MACEDONIAN
00113    0x30 LANG_SUTU
00114    0x31 LANG_TSONGA
00115    0x32 LANG_TSWANA
00116    0x33 LANG_VENDA
00117    0x34 LANG_XHOSA
00118    0x35 LANG_ZULU
00119    0x36 LANG_AFRIKAANS
00120    0x37 LANG_GEORGIAN
00121    0x38 LANG_FAEROESE
00122    0x39 LANG_HINDI
00123    0x3a LANG_MALTESE
00124    0x3b LANG_SAMI
00125    0x3c LANG_GAELIC
00126    0x3d LANG_YIDDISH
00127    0x3e LANG_MALAY
00128    0x3f LANG_KAZAK
00129    0x40 LANG_KYRGYZ
00130    0x41 LANG_SWAHILI
00131    0x42 LANG_TURKMEN
00132    0x43 LANG_UZBEK
00133    0x44 LANG_TATAR
00134    0x45 LANG_BENGALI
00135    0x46 LANG_PUNJABI
00136    0x47 LANG_GUJARATI
00137    0x48 LANG_ORIYA
00138    0x49 LANG_TAMIL
00139    0x4a LANG_TELUGU
00140    0x4b LANG_KANNADA
00141    0x4c LANG_MALAYALAM
00142    0x4d LANG_ASSAMESE
00143    0x4e LANG_MARATHI
00144    0x4f LANG_SANSKRIT
00145    0x50 LANG_MONGOLIAN
00146    0x51 LANG_TIBETAN
00147    0x52 LANG_WELSH
00148    0x53 LANG_CAMBODIAN
00149    0x54 LANG_LAO
00150    0x55 LANG_BURMESE
00151    0x56 LANG_GALICIAN
00152    0x57 LANG_KONKANI
00153    0x58 LANG_MANIPURI
00154    0x59 LANG_SINDHI
00155    0x5a LANG_SYRIAC
00156    0x5b LANG_SINHALESE
00157    0x5c LANG_CHEROKEE
00158    0x5d LANG_INUKTITUT
00159    0x5e LANG_AMHARIC
00160    0x5f LANG_TAMAZIGHT
00161    0x60 LANG_KASHMIRI
00162    0x61 LANG_NEPALI
00163    0x62 LANG_FRISIAN
00164    0x63 LANG_PASHTO
00165    0x64 LANG_TAGALOG
00166    0x65 LANG_DIVEHI
00167    0x66 LANG_EDO
00168    0x67 LANG_FULFULDE
00169    0x68 LANG_HAUSA
00170    0x69 LANG_IBIBIO
00171    0x6a LANG_YORUBA
00172    0x6d LANG_BASHKIR
00173    0x6e LANG_LUXEMBOURGISH
00174    0x6f LANG_GREENLANDIC
00175    0x70 LANG_IGBO
00176    0x71 LANG_KANURI
00177    0x72 LANG_OROMO
00178    0x73 LANG_TIGRINYA
00179    0x74 LANG_GUARANI
00180    0x75 LANG_HAWAIIAN
00181    0x76 LANG_LATIN
00182    0x77 LANG_SOMALI
00183    0x78 LANG_YI
00184    0x79 LANG_PAPIAMENTU
00185    0x7a LANG_MAPUDUNGUN
00186    0x7c LANG_MOHAWK
00187    0x7e LANG_BRETON
00188    0x82 LANG_OCCITAN
00189    0x83 LANG_CORSICAN
00190    0x84 LANG_ALSATIAN
00191    0x85 LANG_YAKUT
00192    0x86 LANG_KICHE
00193    0x87 LANG_KINYARWANDA
00194    0x88 LANG_WOLOF
00195    0x8c LANG_DARI
00196    0x91 LANG_SCOTTISH_GAELIC
00197 */
00198 /* Mingw headers don't have latest language and sublanguage codes.  */
00199 # ifndef LANG_AFRIKAANS
00200 # define LANG_AFRIKAANS 0x36
00201 # endif
00202 # ifndef LANG_ALBANIAN
00203 # define LANG_ALBANIAN 0x1c
00204 # endif
00205 # ifndef LANG_ALSATIAN
00206 # define LANG_ALSATIAN 0x84
00207 # endif
00208 # ifndef LANG_AMHARIC
00209 # define LANG_AMHARIC 0x5e
00210 # endif
00211 # ifndef LANG_ARABIC
00212 # define LANG_ARABIC 0x01
00213 # endif
00214 # ifndef LANG_ARMENIAN
00215 # define LANG_ARMENIAN 0x2b
00216 # endif
00217 # ifndef LANG_ASSAMESE
00218 # define LANG_ASSAMESE 0x4d
00219 # endif
00220 # ifndef LANG_AZERI
00221 # define LANG_AZERI 0x2c
00222 # endif
00223 # ifndef LANG_BASHKIR
00224 # define LANG_BASHKIR 0x6d
00225 # endif
00226 # ifndef LANG_BASQUE
00227 # define LANG_BASQUE 0x2d
00228 # endif
00229 # ifndef LANG_BELARUSIAN
00230 # define LANG_BELARUSIAN 0x23
00231 # endif
00232 # ifndef LANG_BENGALI
00233 # define LANG_BENGALI 0x45
00234 # endif
00235 # ifndef LANG_BRETON
00236 # define LANG_BRETON 0x7e
00237 # endif
00238 # ifndef LANG_BURMESE
00239 # define LANG_BURMESE 0x55
00240 # endif
00241 # ifndef LANG_CAMBODIAN
00242 # define LANG_CAMBODIAN 0x53
00243 # endif
00244 # ifndef LANG_CATALAN
00245 # define LANG_CATALAN 0x03
00246 # endif
00247 # ifndef LANG_CHEROKEE
00248 # define LANG_CHEROKEE 0x5c
00249 # endif
00250 # ifndef LANG_CORSICAN
00251 # define LANG_CORSICAN 0x83
00252 # endif
00253 # ifndef LANG_DARI
00254 # define LANG_DARI 0x8c
00255 # endif
00256 # ifndef LANG_DIVEHI
00257 # define LANG_DIVEHI 0x65
00258 # endif
00259 # ifndef LANG_EDO
00260 # define LANG_EDO 0x66
00261 # endif
00262 # ifndef LANG_ESTONIAN
00263 # define LANG_ESTONIAN 0x25
00264 # endif
00265 # ifndef LANG_FAEROESE
00266 # define LANG_FAEROESE 0x38
00267 # endif
00268 # ifndef LANG_FARSI
00269 # define LANG_FARSI 0x29
00270 # endif
00271 # ifndef LANG_FRISIAN
00272 # define LANG_FRISIAN 0x62
00273 # endif
00274 # ifndef LANG_FULFULDE
00275 # define LANG_FULFULDE 0x67
00276 # endif
00277 # ifndef LANG_GAELIC
00278 # define LANG_GAELIC 0x3c
00279 # endif
00280 # ifndef LANG_GALICIAN
00281 # define LANG_GALICIAN 0x56
00282 # endif
00283 # ifndef LANG_GEORGIAN
00284 # define LANG_GEORGIAN 0x37
00285 # endif
00286 # ifndef LANG_GREENLANDIC
00287 # define LANG_GREENLANDIC 0x6f
00288 # endif
00289 # ifndef LANG_GUARANI
00290 # define LANG_GUARANI 0x74
00291 # endif
00292 # ifndef LANG_GUJARATI
00293 # define LANG_GUJARATI 0x47
00294 # endif
00295 # ifndef LANG_HAUSA
00296 # define LANG_HAUSA 0x68
00297 # endif
00298 # ifndef LANG_HAWAIIAN
00299 # define LANG_HAWAIIAN 0x75
00300 # endif
00301 # ifndef LANG_HEBREW
00302 # define LANG_HEBREW 0x0d
00303 # endif
00304 # ifndef LANG_HINDI
00305 # define LANG_HINDI 0x39
00306 # endif
00307 # ifndef LANG_IBIBIO
00308 # define LANG_IBIBIO 0x69
00309 # endif
00310 # ifndef LANG_IGBO
00311 # define LANG_IGBO 0x70
00312 # endif
00313 # ifndef LANG_INDONESIAN
00314 # define LANG_INDONESIAN 0x21
00315 # endif
00316 # ifndef LANG_INUKTITUT
00317 # define LANG_INUKTITUT 0x5d
00318 # endif
00319 # ifndef LANG_KANNADA
00320 # define LANG_KANNADA 0x4b
00321 # endif
00322 # ifndef LANG_KANURI
00323 # define LANG_KANURI 0x71
00324 # endif
00325 # ifndef LANG_KASHMIRI
00326 # define LANG_KASHMIRI 0x60
00327 # endif
00328 # ifndef LANG_KAZAK
00329 # define LANG_KAZAK 0x3f
00330 # endif
00331 # ifndef LANG_KICHE
00332 # define LANG_KICHE 0x86
00333 # endif
00334 # ifndef LANG_KINYARWANDA
00335 # define LANG_KINYARWANDA 0x87
00336 # endif
00337 # ifndef LANG_KONKANI
00338 # define LANG_KONKANI 0x57
00339 # endif
00340 # ifndef LANG_KYRGYZ
00341 # define LANG_KYRGYZ 0x40
00342 # endif
00343 # ifndef LANG_LAO
00344 # define LANG_LAO 0x54
00345 # endif
00346 # ifndef LANG_LATIN
00347 # define LANG_LATIN 0x76
00348 # endif
00349 # ifndef LANG_LATVIAN
00350 # define LANG_LATVIAN 0x26
00351 # endif
00352 # ifndef LANG_LITHUANIAN
00353 # define LANG_LITHUANIAN 0x27
00354 # endif
00355 # ifndef LANG_LUXEMBOURGISH
00356 # define LANG_LUXEMBOURGISH 0x6e
00357 # endif
00358 # ifndef LANG_MACEDONIAN
00359 # define LANG_MACEDONIAN 0x2f
00360 # endif
00361 # ifndef LANG_MALAY
00362 # define LANG_MALAY 0x3e
00363 # endif
00364 # ifndef LANG_MALAYALAM
00365 # define LANG_MALAYALAM 0x4c
00366 # endif
00367 # ifndef LANG_MALTESE
00368 # define LANG_MALTESE 0x3a
00369 # endif
00370 # ifndef LANG_MANIPURI
00371 # define LANG_MANIPURI 0x58
00372 # endif
00373 # ifndef LANG_MAORI
00374 # define LANG_MAORI 0x81
00375 # endif
00376 # ifndef LANG_MAPUDUNGUN
00377 # define LANG_MAPUDUNGUN 0x7a
00378 # endif
00379 # ifndef LANG_MARATHI
00380 # define LANG_MARATHI 0x4e
00381 # endif
00382 # ifndef LANG_MOHAWK
00383 # define LANG_MOHAWK 0x7c
00384 # endif
00385 # ifndef LANG_MONGOLIAN
00386 # define LANG_MONGOLIAN 0x50
00387 # endif
00388 # ifndef LANG_NEPALI
00389 # define LANG_NEPALI 0x61
00390 # endif
00391 # ifndef LANG_OCCITAN
00392 # define LANG_OCCITAN 0x82
00393 # endif
00394 # ifndef LANG_ORIYA
00395 # define LANG_ORIYA 0x48
00396 # endif
00397 # ifndef LANG_OROMO
00398 # define LANG_OROMO 0x72
00399 # endif
00400 # ifndef LANG_PAPIAMENTU
00401 # define LANG_PAPIAMENTU 0x79
00402 # endif
00403 # ifndef LANG_PASHTO
00404 # define LANG_PASHTO 0x63
00405 # endif
00406 # ifndef LANG_PUNJABI
00407 # define LANG_PUNJABI 0x46
00408 # endif
00409 # ifndef LANG_QUECHUA
00410 # define LANG_QUECHUA 0x6b
00411 # endif
00412 # ifndef LANG_ROMANSH
00413 # define LANG_ROMANSH 0x17
00414 # endif
00415 # ifndef LANG_SAMI
00416 # define LANG_SAMI 0x3b
00417 # endif
00418 # ifndef LANG_SANSKRIT
00419 # define LANG_SANSKRIT 0x4f
00420 # endif
00421 # ifndef LANG_SCOTTISH_GAELIC
00422 # define LANG_SCOTTISH_GAELIC 0x91
00423 # endif
00424 # ifndef LANG_SERBIAN
00425 # define LANG_SERBIAN 0x1a
00426 # endif
00427 # ifndef LANG_SINDHI
00428 # define LANG_SINDHI 0x59
00429 # endif
00430 # ifndef LANG_SINHALESE
00431 # define LANG_SINHALESE 0x5b
00432 # endif
00433 # ifndef LANG_SLOVAK
00434 # define LANG_SLOVAK 0x1b
00435 # endif
00436 # ifndef LANG_SOMALI
00437 # define LANG_SOMALI 0x77
00438 # endif
00439 # ifndef LANG_SORBIAN
00440 # define LANG_SORBIAN 0x2e
00441 # endif
00442 # ifndef LANG_SOTHO
00443 # define LANG_SOTHO 0x6c
00444 # endif
00445 # ifndef LANG_SUTU
00446 # define LANG_SUTU 0x30
00447 # endif
00448 # ifndef LANG_SWAHILI
00449 # define LANG_SWAHILI 0x41
00450 # endif
00451 # ifndef LANG_SYRIAC
00452 # define LANG_SYRIAC 0x5a
00453 # endif
00454 # ifndef LANG_TAGALOG
00455 # define LANG_TAGALOG 0x64
00456 # endif
00457 # ifndef LANG_TAJIK
00458 # define LANG_TAJIK 0x28
00459 # endif
00460 # ifndef LANG_TAMAZIGHT
00461 # define LANG_TAMAZIGHT 0x5f
00462 # endif
00463 # ifndef LANG_TAMIL
00464 # define LANG_TAMIL 0x49
00465 # endif
00466 # ifndef LANG_TATAR
00467 # define LANG_TATAR 0x44
00468 # endif
00469 # ifndef LANG_TELUGU
00470 # define LANG_TELUGU 0x4a
00471 # endif
00472 # ifndef LANG_THAI
00473 # define LANG_THAI 0x1e
00474 # endif
00475 # ifndef LANG_TIBETAN
00476 # define LANG_TIBETAN 0x51
00477 # endif
00478 # ifndef LANG_TIGRINYA
00479 # define LANG_TIGRINYA 0x73
00480 # endif
00481 # ifndef LANG_TSONGA
00482 # define LANG_TSONGA 0x31
00483 # endif
00484 # ifndef LANG_TSWANA
00485 # define LANG_TSWANA 0x32
00486 # endif
00487 # ifndef LANG_TURKMEN
00488 # define LANG_TURKMEN 0x42
00489 # endif
00490 # ifndef LANG_UIGHUR
00491 # define LANG_UIGHUR 0x80
00492 # endif
00493 # ifndef LANG_UKRAINIAN
00494 # define LANG_UKRAINIAN 0x22
00495 # endif
00496 # ifndef LANG_URDU
00497 # define LANG_URDU 0x20
00498 # endif
00499 # ifndef LANG_UZBEK
00500 # define LANG_UZBEK 0x43
00501 # endif
00502 # ifndef LANG_VENDA
00503 # define LANG_VENDA 0x33
00504 # endif
00505 # ifndef LANG_VIETNAMESE
00506 # define LANG_VIETNAMESE 0x2a
00507 # endif
00508 # ifndef LANG_WELSH
00509 # define LANG_WELSH 0x52
00510 # endif
00511 # ifndef LANG_WOLOF
00512 # define LANG_WOLOF 0x88
00513 # endif
00514 # ifndef LANG_XHOSA
00515 # define LANG_XHOSA 0x34
00516 # endif
00517 # ifndef LANG_YAKUT
00518 # define LANG_YAKUT 0x85
00519 # endif
00520 # ifndef LANG_YI
00521 # define LANG_YI 0x78
00522 # endif
00523 # ifndef LANG_YIDDISH
00524 # define LANG_YIDDISH 0x3d
00525 # endif
00526 # ifndef LANG_YORUBA
00527 # define LANG_YORUBA 0x6a
00528 # endif
00529 # ifndef LANG_ZULU
00530 # define LANG_ZULU 0x35
00531 # endif
00532 # ifndef SUBLANG_AFRIKAANS_SOUTH_AFRICA
00533 # define SUBLANG_AFRIKAANS_SOUTH_AFRICA 0x01
00534 # endif
00535 # ifndef SUBLANG_ALBANIAN_ALBANIA
00536 # define SUBLANG_ALBANIAN_ALBANIA 0x01
00537 # endif
00538 # ifndef SUBLANG_ALSATIAN_FRANCE
00539 # define SUBLANG_ALSATIAN_FRANCE 0x01
00540 # endif
00541 # ifndef SUBLANG_AMHARIC_ETHIOPIA
00542 # define SUBLANG_AMHARIC_ETHIOPIA 0x01
00543 # endif
00544 # ifndef SUBLANG_ARABIC_SAUDI_ARABIA
00545 # define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
00546 # endif
00547 # ifndef SUBLANG_ARABIC_IRAQ
00548 # define SUBLANG_ARABIC_IRAQ 0x02
00549 # endif
00550 # ifndef SUBLANG_ARABIC_EGYPT
00551 # define SUBLANG_ARABIC_EGYPT 0x03
00552 # endif
00553 # ifndef SUBLANG_ARABIC_LIBYA
00554 # define SUBLANG_ARABIC_LIBYA 0x04
00555 # endif
00556 # ifndef SUBLANG_ARABIC_ALGERIA
00557 # define SUBLANG_ARABIC_ALGERIA 0x05
00558 # endif
00559 # ifndef SUBLANG_ARABIC_MOROCCO
00560 # define SUBLANG_ARABIC_MOROCCO 0x06
00561 # endif
00562 # ifndef SUBLANG_ARABIC_TUNISIA
00563 # define SUBLANG_ARABIC_TUNISIA 0x07
00564 # endif
00565 # ifndef SUBLANG_ARABIC_OMAN
00566 # define SUBLANG_ARABIC_OMAN 0x08
00567 # endif
00568 # ifndef SUBLANG_ARABIC_YEMEN
00569 # define SUBLANG_ARABIC_YEMEN 0x09
00570 # endif
00571 # ifndef SUBLANG_ARABIC_SYRIA
00572 # define SUBLANG_ARABIC_SYRIA 0x0a
00573 # endif
00574 # ifndef SUBLANG_ARABIC_JORDAN
00575 # define SUBLANG_ARABIC_JORDAN 0x0b
00576 # endif
00577 # ifndef SUBLANG_ARABIC_LEBANON
00578 # define SUBLANG_ARABIC_LEBANON 0x0c
00579 # endif
00580 # ifndef SUBLANG_ARABIC_KUWAIT
00581 # define SUBLANG_ARABIC_KUWAIT 0x0d
00582 # endif
00583 # ifndef SUBLANG_ARABIC_UAE
00584 # define SUBLANG_ARABIC_UAE 0x0e
00585 # endif
00586 # ifndef SUBLANG_ARABIC_BAHRAIN
00587 # define SUBLANG_ARABIC_BAHRAIN 0x0f
00588 # endif
00589 # ifndef SUBLANG_ARABIC_QATAR
00590 # define SUBLANG_ARABIC_QATAR 0x10
00591 # endif
00592 # ifndef SUBLANG_ARMENIAN_ARMENIA
00593 # define SUBLANG_ARMENIAN_ARMENIA 0x01
00594 # endif
00595 # ifndef SUBLANG_ASSAMESE_INDIA
00596 # define SUBLANG_ASSAMESE_INDIA 0x01
00597 # endif
00598 # ifndef SUBLANG_AZERI_LATIN
00599 # define SUBLANG_AZERI_LATIN 0x01
00600 # endif
00601 # ifndef SUBLANG_AZERI_CYRILLIC
00602 # define SUBLANG_AZERI_CYRILLIC 0x02
00603 # endif
00604 # ifndef SUBLANG_BASHKIR_RUSSIA
00605 # define SUBLANG_BASHKIR_RUSSIA 0x01
00606 # endif
00607 # ifndef SUBLANG_BASQUE_BASQUE
00608 # define SUBLANG_BASQUE_BASQUE 0x01
00609 # endif
00610 # ifndef SUBLANG_BELARUSIAN_BELARUS
00611 # define SUBLANG_BELARUSIAN_BELARUS 0x01
00612 # endif
00613 # ifndef SUBLANG_BENGALI_INDIA
00614 # define SUBLANG_BENGALI_INDIA 0x01
00615 # endif
00616 # ifndef SUBLANG_BENGALI_BANGLADESH
00617 # define SUBLANG_BENGALI_BANGLADESH 0x02
00618 # endif
00619 # ifndef SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN
00620 # define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN 0x05
00621 # endif
00622 # ifndef SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC
00623 # define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC 0x08
00624 # endif
00625 # ifndef SUBLANG_BRETON_FRANCE
00626 # define SUBLANG_BRETON_FRANCE 0x01
00627 # endif
00628 # ifndef SUBLANG_BULGARIAN_BULGARIA
00629 # define SUBLANG_BULGARIAN_BULGARIA 0x01
00630 # endif
00631 # ifndef SUBLANG_CAMBODIAN_CAMBODIA
00632 # define SUBLANG_CAMBODIAN_CAMBODIA 0x01
00633 # endif
00634 # ifndef SUBLANG_CATALAN_SPAIN
00635 # define SUBLANG_CATALAN_SPAIN 0x01
00636 # endif
00637 # ifndef SUBLANG_CORSICAN_FRANCE
00638 # define SUBLANG_CORSICAN_FRANCE 0x01
00639 # endif
00640 # ifndef SUBLANG_CROATIAN_CROATIA
00641 # define SUBLANG_CROATIAN_CROATIA 0x01
00642 # endif
00643 # ifndef SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN
00644 # define SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN 0x04
00645 # endif
00646 # ifndef SUBLANG_CHINESE_MACAU
00647 # define SUBLANG_CHINESE_MACAU 0x05
00648 # endif
00649 # ifndef SUBLANG_CZECH_CZECH_REPUBLIC
00650 # define SUBLANG_CZECH_CZECH_REPUBLIC 0x01
00651 # endif
00652 # ifndef SUBLANG_DANISH_DENMARK
00653 # define SUBLANG_DANISH_DENMARK 0x01
00654 # endif
00655 # ifndef SUBLANG_DARI_AFGHANISTAN
00656 # define SUBLANG_DARI_AFGHANISTAN 0x01
00657 # endif
00658 # ifndef SUBLANG_DIVEHI_MALDIVES
00659 # define SUBLANG_DIVEHI_MALDIVES 0x01
00660 # endif
00661 # ifndef SUBLANG_DUTCH_SURINAM
00662 # define SUBLANG_DUTCH_SURINAM 0x03
00663 # endif
00664 # ifndef SUBLANG_ENGLISH_SOUTH_AFRICA
00665 # define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
00666 # endif
00667 # ifndef SUBLANG_ENGLISH_JAMAICA
00668 # define SUBLANG_ENGLISH_JAMAICA 0x08
00669 # endif
00670 # ifndef SUBLANG_ENGLISH_CARIBBEAN
00671 # define SUBLANG_ENGLISH_CARIBBEAN 0x09
00672 # endif
00673 # ifndef SUBLANG_ENGLISH_BELIZE
00674 # define SUBLANG_ENGLISH_BELIZE 0x0a
00675 # endif
00676 # ifndef SUBLANG_ENGLISH_TRINIDAD
00677 # define SUBLANG_ENGLISH_TRINIDAD 0x0b
00678 # endif
00679 # ifndef SUBLANG_ENGLISH_ZIMBABWE
00680 # define SUBLANG_ENGLISH_ZIMBABWE 0x0c
00681 # endif
00682 # ifndef SUBLANG_ENGLISH_PHILIPPINES
00683 # define SUBLANG_ENGLISH_PHILIPPINES 0x0d
00684 # endif
00685 # ifndef SUBLANG_ENGLISH_INDONESIA
00686 # define SUBLANG_ENGLISH_INDONESIA 0x0e
00687 # endif
00688 # ifndef SUBLANG_ENGLISH_HONGKONG
00689 # define SUBLANG_ENGLISH_HONGKONG 0x0f
00690 # endif
00691 # ifndef SUBLANG_ENGLISH_INDIA
00692 # define SUBLANG_ENGLISH_INDIA 0x10
00693 # endif
00694 # ifndef SUBLANG_ENGLISH_MALAYSIA
00695 # define SUBLANG_ENGLISH_MALAYSIA 0x11
00696 # endif
00697 # ifndef SUBLANG_ENGLISH_SINGAPORE
00698 # define SUBLANG_ENGLISH_SINGAPORE 0x12
00699 # endif
00700 # ifndef SUBLANG_ESTONIAN_ESTONIA
00701 # define SUBLANG_ESTONIAN_ESTONIA 0x01
00702 # endif
00703 # ifndef SUBLANG_FAEROESE_FAROE_ISLANDS
00704 # define SUBLANG_FAEROESE_FAROE_ISLANDS 0x01
00705 # endif
00706 # ifndef SUBLANG_FARSI_IRAN
00707 # define SUBLANG_FARSI_IRAN 0x01
00708 # endif
00709 # ifndef SUBLANG_FINNISH_FINLAND
00710 # define SUBLANG_FINNISH_FINLAND 0x01
00711 # endif
00712 # ifndef SUBLANG_FRENCH_LUXEMBOURG
00713 # define SUBLANG_FRENCH_LUXEMBOURG 0x05
00714 # endif
00715 # ifndef SUBLANG_FRENCH_MONACO
00716 # define SUBLANG_FRENCH_MONACO 0x06
00717 # endif
00718 # ifndef SUBLANG_FRENCH_WESTINDIES
00719 # define SUBLANG_FRENCH_WESTINDIES 0x07
00720 # endif
00721 # ifndef SUBLANG_FRENCH_REUNION
00722 # define SUBLANG_FRENCH_REUNION 0x08
00723 # endif
00724 # ifndef SUBLANG_FRENCH_CONGO
00725 # define SUBLANG_FRENCH_CONGO 0x09
00726 # endif
00727 # ifndef SUBLANG_FRENCH_SENEGAL
00728 # define SUBLANG_FRENCH_SENEGAL 0x0a
00729 # endif
00730 # ifndef SUBLANG_FRENCH_CAMEROON
00731 # define SUBLANG_FRENCH_CAMEROON 0x0b
00732 # endif
00733 # ifndef SUBLANG_FRENCH_COTEDIVOIRE
00734 # define SUBLANG_FRENCH_COTEDIVOIRE 0x0c
00735 # endif
00736 # ifndef SUBLANG_FRENCH_MALI
00737 # define SUBLANG_FRENCH_MALI 0x0d
00738 # endif
00739 # ifndef SUBLANG_FRENCH_MOROCCO
00740 # define SUBLANG_FRENCH_MOROCCO 0x0e
00741 # endif
00742 # ifndef SUBLANG_FRENCH_HAITI
00743 # define SUBLANG_FRENCH_HAITI 0x0f
00744 # endif
00745 # ifndef SUBLANG_FRISIAN_NETHERLANDS
00746 # define SUBLANG_FRISIAN_NETHERLANDS 0x01
00747 # endif
00748 # ifndef SUBLANG_GALICIAN_SPAIN
00749 # define SUBLANG_GALICIAN_SPAIN 0x01
00750 # endif
00751 # ifndef SUBLANG_GEORGIAN_GEORGIA
00752 # define SUBLANG_GEORGIAN_GEORGIA 0x01
00753 # endif
00754 # ifndef SUBLANG_GERMAN_LUXEMBOURG
00755 # define SUBLANG_GERMAN_LUXEMBOURG 0x04
00756 # endif
00757 # ifndef SUBLANG_GERMAN_LIECHTENSTEIN
00758 # define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
00759 # endif
00760 # ifndef SUBLANG_GREEK_GREECE
00761 # define SUBLANG_GREEK_GREECE 0x01
00762 # endif
00763 # ifndef SUBLANG_GREENLANDIC_GREENLAND
00764 # define SUBLANG_GREENLANDIC_GREENLAND 0x01
00765 # endif
00766 # ifndef SUBLANG_GUJARATI_INDIA
00767 # define SUBLANG_GUJARATI_INDIA 0x01
00768 # endif
00769 # ifndef SUBLANG_HAUSA_NIGERIA_LATIN
00770 # define SUBLANG_HAUSA_NIGERIA_LATIN 0x01
00771 # endif
00772 # ifndef SUBLANG_HEBREW_ISRAEL
00773 # define SUBLANG_HEBREW_ISRAEL 0x01
00774 # endif
00775 # ifndef SUBLANG_HINDI_INDIA
00776 # define SUBLANG_HINDI_INDIA 0x01
00777 # endif
00778 # ifndef SUBLANG_HUNGARIAN_HUNGARY
00779 # define SUBLANG_HUNGARIAN_HUNGARY 0x01
00780 # endif
00781 # ifndef SUBLANG_ICELANDIC_ICELAND
00782 # define SUBLANG_ICELANDIC_ICELAND 0x01
00783 # endif
00784 # ifndef SUBLANG_IGBO_NIGERIA
00785 # define SUBLANG_IGBO_NIGERIA 0x01
00786 # endif
00787 # ifndef SUBLANG_INDONESIAN_INDONESIA
00788 # define SUBLANG_INDONESIAN_INDONESIA 0x01
00789 # endif
00790 # ifndef SUBLANG_INUKTITUT_CANADA
00791 # define SUBLANG_INUKTITUT_CANADA 0x01
00792 # endif
00793 # undef SUBLANG_INUKTITUT_CANADA_LATIN
00794 # define SUBLANG_INUKTITUT_CANADA_LATIN 0x02
00795 # undef SUBLANG_IRISH_IRELAND
00796 # define SUBLANG_IRISH_IRELAND 0x02
00797 # ifndef SUBLANG_JAPANESE_JAPAN
00798 # define SUBLANG_JAPANESE_JAPAN 0x01
00799 # endif
00800 # ifndef SUBLANG_KANNADA_INDIA
00801 # define SUBLANG_KANNADA_INDIA 0x01
00802 # endif
00803 # ifndef SUBLANG_KASHMIRI_INDIA
00804 # define SUBLANG_KASHMIRI_INDIA 0x02
00805 # endif
00806 # ifndef SUBLANG_KAZAK_KAZAKHSTAN
00807 # define SUBLANG_KAZAK_KAZAKHSTAN 0x01
00808 # endif
00809 # ifndef SUBLANG_KICHE_GUATEMALA
00810 # define SUBLANG_KICHE_GUATEMALA 0x01
00811 # endif
00812 # ifndef SUBLANG_KINYARWANDA_RWANDA
00813 # define SUBLANG_KINYARWANDA_RWANDA 0x01
00814 # endif
00815 # ifndef SUBLANG_KONKANI_INDIA
00816 # define SUBLANG_KONKANI_INDIA 0x01
00817 # endif
00818 # ifndef SUBLANG_KYRGYZ_KYRGYZSTAN
00819 # define SUBLANG_KYRGYZ_KYRGYZSTAN 0x01
00820 # endif
00821 # ifndef SUBLANG_LAO_LAOS
00822 # define SUBLANG_LAO_LAOS 0x01
00823 # endif
00824 # ifndef SUBLANG_LATVIAN_LATVIA
00825 # define SUBLANG_LATVIAN_LATVIA 0x01
00826 # endif
00827 # ifndef SUBLANG_LITHUANIAN_LITHUANIA
00828 # define SUBLANG_LITHUANIAN_LITHUANIA 0x01
00829 # endif
00830 # undef SUBLANG_LOWER_SORBIAN_GERMANY
00831 # define SUBLANG_LOWER_SORBIAN_GERMANY 0x02
00832 # ifndef SUBLANG_LUXEMBOURGISH_LUXEMBOURG
00833 # define SUBLANG_LUXEMBOURGISH_LUXEMBOURG 0x01
00834 # endif
00835 # ifndef SUBLANG_MACEDONIAN_MACEDONIA
00836 # define SUBLANG_MACEDONIAN_MACEDONIA 0x01
00837 # endif
00838 # ifndef SUBLANG_MALAY_MALAYSIA
00839 # define SUBLANG_MALAY_MALAYSIA 0x01
00840 # endif
00841 # ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM
00842 # define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
00843 # endif
00844 # ifndef SUBLANG_MALAYALAM_INDIA
00845 # define SUBLANG_MALAYALAM_INDIA 0x01
00846 # endif
00847 # ifndef SUBLANG_MALTESE_MALTA
00848 # define SUBLANG_MALTESE_MALTA 0x01
00849 # endif
00850 # ifndef SUBLANG_MAORI_NEW_ZEALAND
00851 # define SUBLANG_MAORI_NEW_ZEALAND 0x01
00852 # endif
00853 # ifndef SUBLANG_MAPUDUNGUN_CHILE
00854 # define SUBLANG_MAPUDUNGUN_CHILE 0x01
00855 # endif
00856 # ifndef SUBLANG_MARATHI_INDIA
00857 # define SUBLANG_MARATHI_INDIA 0x01
00858 # endif
00859 # ifndef SUBLANG_MOHAWK_CANADA
00860 # define SUBLANG_MOHAWK_CANADA 0x01
00861 # endif
00862 # ifndef SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA
00863 # define SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA 0x01
00864 # endif
00865 # ifndef SUBLANG_MONGOLIAN_PRC
00866 # define SUBLANG_MONGOLIAN_PRC 0x02
00867 # endif
00868 # ifndef SUBLANG_NEPALI_NEPAL
00869 # define SUBLANG_NEPALI_NEPAL 0x01
00870 # endif
00871 # ifndef SUBLANG_NEPALI_INDIA
00872 # define SUBLANG_NEPALI_INDIA 0x02
00873 # endif
00874 # ifndef SUBLANG_OCCITAN_FRANCE
00875 # define SUBLANG_OCCITAN_FRANCE 0x01
00876 # endif
00877 # ifndef SUBLANG_ORIYA_INDIA
00878 # define SUBLANG_ORIYA_INDIA 0x01
00879 # endif
00880 # ifndef SUBLANG_PASHTO_AFGHANISTAN
00881 # define SUBLANG_PASHTO_AFGHANISTAN 0x01
00882 # endif
00883 # ifndef SUBLANG_POLISH_POLAND
00884 # define SUBLANG_POLISH_POLAND 0x01
00885 # endif
00886 # ifndef SUBLANG_PUNJABI_INDIA
00887 # define SUBLANG_PUNJABI_INDIA 0x01
00888 # endif
00889 # ifndef SUBLANG_PUNJABI_PAKISTAN
00890 # define SUBLANG_PUNJABI_PAKISTAN 0x02
00891 # endif
00892 # ifndef SUBLANG_QUECHUA_BOLIVIA
00893 # define SUBLANG_QUECHUA_BOLIVIA 0x01
00894 # endif
00895 # ifndef SUBLANG_QUECHUA_ECUADOR
00896 # define SUBLANG_QUECHUA_ECUADOR 0x02
00897 # endif
00898 # ifndef SUBLANG_QUECHUA_PERU
00899 # define SUBLANG_QUECHUA_PERU 0x03
00900 # endif
00901 # ifndef SUBLANG_ROMANIAN_ROMANIA
00902 # define SUBLANG_ROMANIAN_ROMANIA 0x01
00903 # endif
00904 # ifndef SUBLANG_ROMANIAN_MOLDOVA
00905 # define SUBLANG_ROMANIAN_MOLDOVA 0x02
00906 # endif
00907 # ifndef SUBLANG_ROMANSH_SWITZERLAND
00908 # define SUBLANG_ROMANSH_SWITZERLAND 0x01
00909 # endif
00910 # ifndef SUBLANG_RUSSIAN_RUSSIA
00911 # define SUBLANG_RUSSIAN_RUSSIA 0x01
00912 # endif
00913 # ifndef SUBLANG_RUSSIAN_MOLDAVIA
00914 # define SUBLANG_RUSSIAN_MOLDAVIA 0x02
00915 # endif
00916 # ifndef SUBLANG_SAMI_NORTHERN_NORWAY
00917 # define SUBLANG_SAMI_NORTHERN_NORWAY 0x01
00918 # endif
00919 # ifndef SUBLANG_SAMI_NORTHERN_SWEDEN
00920 # define SUBLANG_SAMI_NORTHERN_SWEDEN 0x02
00921 # endif
00922 # ifndef SUBLANG_SAMI_NORTHERN_FINLAND
00923 # define SUBLANG_SAMI_NORTHERN_FINLAND 0x03
00924 # endif
00925 # ifndef SUBLANG_SAMI_LULE_NORWAY
00926 # define SUBLANG_SAMI_LULE_NORWAY 0x04
00927 # endif
00928 # ifndef SUBLANG_SAMI_LULE_SWEDEN
00929 # define SUBLANG_SAMI_LULE_SWEDEN 0x05
00930 # endif
00931 # ifndef SUBLANG_SAMI_SOUTHERN_NORWAY
00932 # define SUBLANG_SAMI_SOUTHERN_NORWAY 0x06
00933 # endif
00934 # ifndef SUBLANG_SAMI_SOUTHERN_SWEDEN
00935 # define SUBLANG_SAMI_SOUTHERN_SWEDEN 0x07
00936 # endif
00937 # undef SUBLANG_SAMI_SKOLT_FINLAND
00938 # define SUBLANG_SAMI_SKOLT_FINLAND 0x08
00939 # undef SUBLANG_SAMI_INARI_FINLAND
00940 # define SUBLANG_SAMI_INARI_FINLAND 0x09
00941 # ifndef SUBLANG_SANSKRIT_INDIA
00942 # define SUBLANG_SANSKRIT_INDIA 0x01
00943 # endif
00944 # ifndef SUBLANG_SERBIAN_LATIN
00945 # define SUBLANG_SERBIAN_LATIN 0x02
00946 # endif
00947 # ifndef SUBLANG_SERBIAN_CYRILLIC
00948 # define SUBLANG_SERBIAN_CYRILLIC 0x03
00949 # endif
00950 # ifndef SUBLANG_SINDHI_INDIA
00951 # define SUBLANG_SINDHI_INDIA 0x01
00952 # endif
00953 # undef SUBLANG_SINDHI_PAKISTAN
00954 # define SUBLANG_SINDHI_PAKISTAN 0x02
00955 # ifndef SUBLANG_SINDHI_AFGHANISTAN
00956 # define SUBLANG_SINDHI_AFGHANISTAN 0x02
00957 # endif
00958 # ifndef SUBLANG_SINHALESE_SRI_LANKA
00959 # define SUBLANG_SINHALESE_SRI_LANKA 0x01
00960 # endif
00961 # ifndef SUBLANG_SLOVAK_SLOVAKIA
00962 # define SUBLANG_SLOVAK_SLOVAKIA 0x01
00963 # endif
00964 # ifndef SUBLANG_SLOVENIAN_SLOVENIA
00965 # define SUBLANG_SLOVENIAN_SLOVENIA 0x01
00966 # endif
00967 # ifndef SUBLANG_SOTHO_SOUTH_AFRICA
00968 # define SUBLANG_SOTHO_SOUTH_AFRICA 0x01
00969 # endif
00970 # ifndef SUBLANG_SPANISH_GUATEMALA
00971 # define SUBLANG_SPANISH_GUATEMALA 0x04
00972 # endif
00973 # ifndef SUBLANG_SPANISH_COSTA_RICA
00974 # define SUBLANG_SPANISH_COSTA_RICA 0x05
00975 # endif
00976 # ifndef SUBLANG_SPANISH_PANAMA
00977 # define SUBLANG_SPANISH_PANAMA 0x06
00978 # endif
00979 # ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
00980 # define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
00981 # endif
00982 # ifndef SUBLANG_SPANISH_VENEZUELA
00983 # define SUBLANG_SPANISH_VENEZUELA 0x08
00984 # endif
00985 # ifndef SUBLANG_SPANISH_COLOMBIA
00986 # define SUBLANG_SPANISH_COLOMBIA 0x09
00987 # endif
00988 # ifndef SUBLANG_SPANISH_PERU
00989 # define SUBLANG_SPANISH_PERU 0x0a
00990 # endif
00991 # ifndef SUBLANG_SPANISH_ARGENTINA
00992 # define SUBLANG_SPANISH_ARGENTINA 0x0b
00993 # endif
00994 # ifndef SUBLANG_SPANISH_ECUADOR
00995 # define SUBLANG_SPANISH_ECUADOR 0x0c
00996 # endif
00997 # ifndef SUBLANG_SPANISH_CHILE
00998 # define SUBLANG_SPANISH_CHILE 0x0d
00999 # endif
01000 # ifndef SUBLANG_SPANISH_URUGUAY
01001 # define SUBLANG_SPANISH_URUGUAY 0x0e
01002 # endif
01003 # ifndef SUBLANG_SPANISH_PARAGUAY
01004 # define SUBLANG_SPANISH_PARAGUAY 0x0f
01005 # endif
01006 # ifndef SUBLANG_SPANISH_BOLIVIA
01007 # define SUBLANG_SPANISH_BOLIVIA 0x10
01008 # endif
01009 # ifndef SUBLANG_SPANISH_EL_SALVADOR
01010 # define SUBLANG_SPANISH_EL_SALVADOR 0x11
01011 # endif
01012 # ifndef SUBLANG_SPANISH_HONDURAS
01013 # define SUBLANG_SPANISH_HONDURAS 0x12
01014 # endif
01015 # ifndef SUBLANG_SPANISH_NICARAGUA
01016 # define SUBLANG_SPANISH_NICARAGUA 0x13
01017 # endif
01018 # ifndef SUBLANG_SPANISH_PUERTO_RICO
01019 # define SUBLANG_SPANISH_PUERTO_RICO 0x14
01020 # endif
01021 # ifndef SUBLANG_SPANISH_US
01022 # define SUBLANG_SPANISH_US 0x15
01023 # endif
01024 # ifndef SUBLANG_SWAHILI_KENYA
01025 # define SUBLANG_SWAHILI_KENYA 0x01
01026 # endif
01027 # ifndef SUBLANG_SWEDISH_SWEDEN
01028 # define SUBLANG_SWEDISH_SWEDEN 0x01
01029 # endif
01030 # ifndef SUBLANG_SWEDISH_FINLAND
01031 # define SUBLANG_SWEDISH_FINLAND 0x02
01032 # endif
01033 # ifndef SUBLANG_SYRIAC_SYRIA
01034 # define SUBLANG_SYRIAC_SYRIA 0x01
01035 # endif
01036 # ifndef SUBLANG_TAGALOG_PHILIPPINES
01037 # define SUBLANG_TAGALOG_PHILIPPINES 0x01
01038 # endif
01039 # ifndef SUBLANG_TAJIK_TAJIKISTAN
01040 # define SUBLANG_TAJIK_TAJIKISTAN 0x01
01041 # endif
01042 # ifndef SUBLANG_TAMAZIGHT_ARABIC
01043 # define SUBLANG_TAMAZIGHT_ARABIC 0x01
01044 # endif
01045 # ifndef SUBLANG_TAMAZIGHT_ALGERIA_LATIN
01046 # define SUBLANG_TAMAZIGHT_ALGERIA_LATIN 0x02
01047 # endif
01048 # ifndef SUBLANG_TAMIL_INDIA
01049 # define SUBLANG_TAMIL_INDIA 0x01
01050 # endif
01051 # ifndef SUBLANG_TATAR_RUSSIA
01052 # define SUBLANG_TATAR_RUSSIA 0x01
01053 # endif
01054 # ifndef SUBLANG_TELUGU_INDIA
01055 # define SUBLANG_TELUGU_INDIA 0x01
01056 # endif
01057 # ifndef SUBLANG_THAI_THAILAND
01058 # define SUBLANG_THAI_THAILAND 0x01
01059 # endif
01060 # ifndef SUBLANG_TIBETAN_PRC
01061 # define SUBLANG_TIBETAN_PRC 0x01
01062 # endif
01063 # undef SUBLANG_TIBETAN_BHUTAN
01064 # define SUBLANG_TIBETAN_BHUTAN 0x02
01065 # ifndef SUBLANG_TIGRINYA_ETHIOPIA
01066 # define SUBLANG_TIGRINYA_ETHIOPIA 0x01
01067 # endif
01068 # ifndef SUBLANG_TIGRINYA_ERITREA
01069 # define SUBLANG_TIGRINYA_ERITREA 0x02
01070 # endif
01071 # ifndef SUBLANG_TSWANA_SOUTH_AFRICA
01072 # define SUBLANG_TSWANA_SOUTH_AFRICA 0x01
01073 # endif
01074 # ifndef SUBLANG_TURKISH_TURKEY
01075 # define SUBLANG_TURKISH_TURKEY 0x01
01076 # endif
01077 # ifndef SUBLANG_TURKMEN_TURKMENISTAN
01078 # define SUBLANG_TURKMEN_TURKMENISTAN 0x01
01079 # endif
01080 # ifndef SUBLANG_UIGHUR_PRC
01081 # define SUBLANG_UIGHUR_PRC 0x01
01082 # endif
01083 # ifndef SUBLANG_UKRAINIAN_UKRAINE
01084 # define SUBLANG_UKRAINIAN_UKRAINE 0x01
01085 # endif
01086 # ifndef SUBLANG_UPPER_SORBIAN_GERMANY
01087 # define SUBLANG_UPPER_SORBIAN_GERMANY 0x01
01088 # endif
01089 # ifndef SUBLANG_URDU_PAKISTAN
01090 # define SUBLANG_URDU_PAKISTAN 0x01
01091 # endif
01092 # ifndef SUBLANG_URDU_INDIA
01093 # define SUBLANG_URDU_INDIA 0x02
01094 # endif
01095 # ifndef SUBLANG_UZBEK_LATIN
01096 # define SUBLANG_UZBEK_LATIN 0x01
01097 # endif
01098 # ifndef SUBLANG_UZBEK_CYRILLIC
01099 # define SUBLANG_UZBEK_CYRILLIC 0x02
01100 # endif
01101 # ifndef SUBLANG_VIETNAMESE_VIETNAM
01102 # define SUBLANG_VIETNAMESE_VIETNAM 0x01
01103 # endif
01104 # ifndef SUBLANG_WELSH_UNITED_KINGDOM
01105 # define SUBLANG_WELSH_UNITED_KINGDOM 0x01
01106 # endif
01107 # ifndef SUBLANG_WOLOF_SENEGAL
01108 # define SUBLANG_WOLOF_SENEGAL 0x01
01109 # endif
01110 # ifndef SUBLANG_XHOSA_SOUTH_AFRICA
01111 # define SUBLANG_XHOSA_SOUTH_AFRICA 0x01
01112 # endif
01113 # ifndef SUBLANG_YAKUT_RUSSIA
01114 # define SUBLANG_YAKUT_RUSSIA 0x01
01115 # endif
01116 # ifndef SUBLANG_YI_PRC
01117 # define SUBLANG_YI_PRC 0x01
01118 # endif
01119 # ifndef SUBLANG_YORUBA_NIGERIA
01120 # define SUBLANG_YORUBA_NIGERIA 0x01
01121 # endif
01122 # ifndef SUBLANG_ZULU_SOUTH_AFRICA
01123 # define SUBLANG_ZULU_SOUTH_AFRICA 0x01
01124 # endif
01125 /* GetLocaleInfoA operations.  */
01126 # ifndef LOCALE_SNAME
01127 # define LOCALE_SNAME 0x5c
01128 # endif
01129 #endif
01130 
01131 
01132 #if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
01133 /* MacOS X 10.2 or newer */
01134 
01135 /* Canonicalize a MacOS X locale name to a Unix locale name.
01136    NAME is a sufficiently large buffer.
01137    On input, it contains the MacOS X locale name.
01138    On output, it contains the Unix locale name.  */
01139 # if !defined IN_LIBINTL
01140 static
01141 # endif
01142 void
01143 gl_locale_name_canonicalize (char *name)
01144 {
01145   /* This conversion is based on a posting by
01146      Deborah GoldSmith <goldsmit@apple.com> on 2005-03-08,
01147      http://lists.apple.com/archives/carbon-dev/2005/Mar/msg00293.html */
01148 
01149   /* Convert legacy (NeXTstep inherited) English names to Unix (ISO 639 and
01150      ISO 3166) names.  Prior to MacOS X 10.3, there is no API for doing this.
01151      Therefore we do it ourselves, using a table based on the results of the
01152      MacOS X 10.3.8 function
01153      CFLocaleCreateCanonicalLocaleIdentifierFromString().  */
01154   typedef struct { const char legacy[21+1]; const char unixy[5+1]; }
01155           legacy_entry;
01156   static const legacy_entry legacy_table[] = {
01157     { "Afrikaans",             "af" },
01158     { "Albanian",              "sq" },
01159     { "Amharic",               "am" },
01160     { "Arabic",                "ar" },
01161     { "Armenian",              "hy" },
01162     { "Assamese",              "as" },
01163     { "Aymara",                "ay" },
01164     { "Azerbaijani",           "az" },
01165     { "Basque",                "eu" },
01166     { "Belarusian",            "be" },
01167     { "Belorussian",           "be" },
01168     { "Bengali",               "bn" },
01169     { "Brazilian Portugese",   "pt_BR" },
01170     { "Brazilian Portuguese",  "pt_BR" },
01171     { "Breton",                "br" },
01172     { "Bulgarian",             "bg" },
01173     { "Burmese",               "my" },
01174     { "Byelorussian",          "be" },
01175     { "Catalan",               "ca" },
01176     { "Chewa",                 "ny" },
01177     { "Chichewa",              "ny" },
01178     { "Chinese",               "zh" },
01179     { "Chinese, Simplified",   "zh_CN" },
01180     { "Chinese, Traditional",  "zh_TW" },
01181     { "Chinese, Tradtional",   "zh_TW" },
01182     { "Croatian",              "hr" },
01183     { "Czech",                 "cs" },
01184     { "Danish",                "da" },
01185     { "Dutch",                 "nl" },
01186     { "Dzongkha",              "dz" },
01187     { "English",               "en" },
01188     { "Esperanto",             "eo" },
01189     { "Estonian",              "et" },
01190     { "Faroese",               "fo" },
01191     { "Farsi",                 "fa" },
01192     { "Finnish",               "fi" },
01193     { "Flemish",               "nl_BE" },
01194     { "French",                "fr" },
01195     { "Galician",              "gl" },
01196     { "Gallegan",              "gl" },
01197     { "Georgian",              "ka" },
01198     { "German",                "de" },
01199     { "Greek",                 "el" },
01200     { "Greenlandic",           "kl" },
01201     { "Guarani",               "gn" },
01202     { "Gujarati",              "gu" },
01203     { "Hawaiian",              "haw" }, /* Yes, "haw", not "cpe".  */
01204     { "Hebrew",                "he" },
01205     { "Hindi",                 "hi" },
01206     { "Hungarian",             "hu" },
01207     { "Icelandic",             "is" },
01208     { "Indonesian",            "id" },
01209     { "Inuktitut",             "iu" },
01210     { "Irish",                 "ga" },
01211     { "Italian",               "it" },
01212     { "Japanese",              "ja" },
01213     { "Javanese",              "jv" },
01214     { "Kalaallisut",           "kl" },
01215     { "Kannada",               "kn" },
01216     { "Kashmiri",              "ks" },
01217     { "Kazakh",                "kk" },
01218     { "Khmer",                 "km" },
01219     { "Kinyarwanda",           "rw" },
01220     { "Kirghiz",               "ky" },
01221     { "Korean",                "ko" },
01222     { "Kurdish",               "ku" },
01223     { "Latin",                 "la" },
01224     { "Latvian",               "lv" },
01225     { "Lithuanian",            "lt" },
01226     { "Macedonian",            "mk" },
01227     { "Malagasy",              "mg" },
01228     { "Malay",                 "ms" },
01229     { "Malayalam",             "ml" },
01230     { "Maltese",               "mt" },
01231     { "Manx",                  "gv" },
01232     { "Marathi",               "mr" },
01233     { "Moldavian",             "mo" },
01234     { "Mongolian",             "mn" },
01235     { "Nepali",                "ne" },
01236     { "Norwegian",             "nb" }, /* Yes, "nb", not the obsolete "no".  */
01237     { "Nyanja",                "ny" },
01238     { "Nynorsk",               "nn" },
01239     { "Oriya",                 "or" },
01240     { "Oromo",                 "om" },
01241     { "Panjabi",               "pa" },
01242     { "Pashto",                "ps" },
01243     { "Persian",               "fa" },
01244     { "Polish",                "pl" },
01245     { "Portuguese",            "pt" },
01246     { "Portuguese, Brazilian", "pt_BR" },
01247     { "Punjabi",               "pa" },
01248     { "Pushto",                "ps" },
01249     { "Quechua",               "qu" },
01250     { "Romanian",              "ro" },
01251     { "Ruanda",                "rw" },
01252     { "Rundi",                 "rn" },
01253     { "Russian",               "ru" },
01254     { "Sami",                  "se_NO" }, /* Not just "se".  */
01255     { "Sanskrit",              "sa" },
01256     { "Scottish",              "gd" },
01257     { "Serbian",               "sr" },
01258     { "Simplified Chinese",    "zh_CN" },
01259     { "Sindhi",                "sd" },
01260     { "Sinhalese",             "si" },
01261     { "Slovak",                "sk" },
01262     { "Slovenian",             "sl" },
01263     { "Somali",                "so" },
01264     { "Spanish",               "es" },
01265     { "Sundanese",             "su" },
01266     { "Swahili",               "sw" },
01267     { "Swedish",               "sv" },
01268     { "Tagalog",               "tl" },
01269     { "Tajik",                 "tg" },
01270     { "Tajiki",                "tg" },
01271     { "Tamil",                 "ta" },
01272     { "Tatar",                 "tt" },
01273     { "Telugu",                "te" },
01274     { "Thai",                  "th" },
01275     { "Tibetan",               "bo" },
01276     { "Tigrinya",              "ti" },
01277     { "Tongan",                "to" },
01278     { "Traditional Chinese",   "zh_TW" },
01279     { "Turkish",               "tr" },
01280     { "Turkmen",               "tk" },
01281     { "Uighur",                "ug" },
01282     { "Ukrainian",             "uk" },
01283     { "Urdu",                  "ur" },
01284     { "Uzbek",                 "uz" },
01285     { "Vietnamese",            "vi" },
01286     { "Welsh",                 "cy" },
01287     { "Yiddish",               "yi" }
01288   };
01289 
01290   /* Convert new-style locale names with language tags (ISO 639 and ISO 15924)
01291      to Unix (ISO 639 and ISO 3166) names.  */
01292   typedef struct { const char langtag[7+1]; const char unixy[12+1]; }
01293           langtag_entry;
01294   static const langtag_entry langtag_table[] = {
01295     /* MacOS X has "az-Arab", "az-Cyrl", "az-Latn".
01296        The default script for az on Unix is Latin.  */
01297     { "az-Latn", "az" },
01298     /* MacOS X has "ga-dots".  Does not yet exist on Unix.  */
01299     { "ga-dots", "ga" },
01300     /* MacOS X has "kk-Cyrl".  Does not yet exist on Unix.  */
01301     /* MacOS X has "mn-Cyrl", "mn-Mong".
01302        The default script for mn on Unix is Cyrillic.  */
01303     { "mn-Cyrl", "mn" },
01304     /* MacOS X has "ms-Arab", "ms-Latn".
01305        The default script for ms on Unix is Latin.  */
01306     { "ms-Latn", "ms" },
01307     /* MacOS X has "tg-Cyrl".
01308        The default script for tg on Unix is Cyrillic.  */
01309     { "tg-Cyrl", "tg" },
01310     /* MacOS X has "tk-Cyrl".  Does not yet exist on Unix.  */
01311     /* MacOS X has "tt-Cyrl".
01312        The default script for tt on Unix is Cyrillic.  */
01313     { "tt-Cyrl", "tt" },
01314     /* MacOS X has "zh-Hans", "zh-Hant".
01315        Country codes are used to distinguish these on Unix.  */
01316     { "zh-Hans", "zh_CN" },
01317     { "zh-Hant", "zh_TW" }
01318   };
01319 
01320   /* Convert script names (ISO 15924) to Unix conventions.
01321      See http://www.unicode.org/iso15924/iso15924-codes.html  */
01322   typedef struct { const char script[4+1]; const char unixy[9+1]; }
01323           script_entry;
01324   static const script_entry script_table[] = {
01325     { "Arab", "arabic" },
01326     { "Cyrl", "cyrillic" },
01327     { "Mong", "mongolian" }
01328   };
01329 
01330   /* Step 1: Convert using legacy_table.  */
01331   if (name[0] >= 'A' && name[0] <= 'Z')
01332     {
01333       unsigned int i1, i2;
01334       i1 = 0;
01335       i2 = sizeof (legacy_table) / sizeof (legacy_entry);
01336       while (i2 - i1 > 1)
01337         {
01338           /* At this point we know that if name occurs in legacy_table,
01339              its index must be >= i1 and < i2.  */
01340           unsigned int i = (i1 + i2) >> 1;
01341           const legacy_entry *p = &legacy_table[i];
01342           if (strcmp (name, p->legacy) < 0)
01343             i2 = i;
01344           else
01345             i1 = i;
01346         }
01347       if (strcmp (name, legacy_table[i1].legacy) == 0)
01348         {
01349           strcpy (name, legacy_table[i1].unixy);
01350           return;
01351         }
01352     }
01353 
01354   /* Step 2: Convert using langtag_table and script_table.  */
01355   if (strlen (name) == 7 && name[2] == '-')
01356     {
01357       unsigned int i1, i2;
01358       i1 = 0;
01359       i2 = sizeof (langtag_table) / sizeof (langtag_entry);
01360       while (i2 - i1 > 1)
01361         {
01362           /* At this point we know that if name occurs in langtag_table,
01363              its index must be >= i1 and < i2.  */
01364           unsigned int i = (i1 + i2) >> 1;
01365           const langtag_entry *p = &langtag_table[i];
01366           if (strcmp (name, p->langtag) < 0)
01367             i2 = i;
01368           else
01369             i1 = i;
01370         }
01371       if (strcmp (name, langtag_table[i1].langtag) == 0)
01372         {
01373           strcpy (name, langtag_table[i1].unixy);
01374           return;
01375         }
01376 
01377       i1 = 0;
01378       i2 = sizeof (script_table) / sizeof (script_entry);
01379       while (i2 - i1 > 1)
01380         {
01381           /* At this point we know that if (name + 3) occurs in script_table,
01382              its index must be >= i1 and < i2.  */
01383           unsigned int i = (i1 + i2) >> 1;
01384           const script_entry *p = &script_table[i];
01385           if (strcmp (name + 3, p->script) < 0)
01386             i2 = i;
01387           else
01388             i1 = i;
01389         }
01390       if (strcmp (name + 3, script_table[i1].script) == 0)
01391         {
01392           name[2] = '@';
01393           strcpy (name + 3, script_table[i1].unixy);
01394           return;
01395         }
01396     }
01397 
01398   /* Step 3: Convert new-style dash to Unix underscore. */
01399   {
01400     char *p;
01401     for (p = name; *p != '\0'; p++)
01402       if (*p == '-')
01403         *p = '_';
01404   }
01405 }
01406 
01407 #endif
01408 
01409 
01410 #if defined WIN32_NATIVE || defined __CYGWIN__ /* WIN32 or Cygwin */
01411 
01412 /* Canonicalize a Win32 native locale name to a Unix locale name.
01413    NAME is a sufficiently large buffer.
01414    On input, it contains the Win32 locale name.
01415    On output, it contains the Unix locale name.  */
01416 # if !defined IN_LIBINTL
01417 static
01418 # endif
01419 void
01420 gl_locale_name_canonicalize (char *name)
01421 {
01422   /* FIXME: This is probably incomplete: it does not handle "zh-Hans" and
01423      "zh-Hant".  */
01424   char *p;
01425 
01426   for (p = name; *p != '\0'; p++)
01427     if (*p == '-')
01428       {
01429         *p = '_';
01430         p++;
01431         for (; *p != '\0'; p++)
01432           {
01433             if (*p >= 'a' && *p <= 'z')
01434               *p += 'A' - 'a';
01435             if (*p == '-')
01436               {
01437                 *p = '\0';
01438                 return;
01439               }
01440           }
01441         return;
01442       }
01443 }
01444 
01445 # if !defined IN_LIBINTL
01446 static
01447 # endif
01448 const char *
01449 gl_locale_name_from_win32_LANGID (LANGID langid)
01450 {
01451   /* Activate the new code only when the GETTEXT_MUI environment variable is
01452      set, for the time being, since the new code is not well tested.  */
01453   if (getenv ("GETTEXT_MUI") != NULL)
01454     {
01455       static char namebuf[256];
01456 
01457       /* Query the system's notion of locale name.
01458          On Windows95/98/ME, GetLocaleInfoA returns some incorrect results.
01459          But we don't need to support systems that are so old.  */
01460       if (GetLocaleInfoA (MAKELCID (langid, SORT_DEFAULT), LOCALE_SNAME,
01461                           namebuf, sizeof (namebuf) - 1))
01462         {
01463           /* Convert it to a Unix locale name.  */
01464           gl_locale_name_canonicalize (namebuf);
01465           return namebuf;
01466         }
01467     }
01468   /* Internet Explorer has an LCID to RFC3066 name mapping stored in
01469      HKEY_CLASSES_ROOT\Mime\Database\Rfc1766.  But we better don't use that
01470      since IE's i18n subsystem is known to be inconsistent with the Win32 base
01471      (e.g. they have different character conversion facilities that produce
01472      different results).  */
01473   /* Use our own table.  */
01474   {
01475     int primary, sub;
01476 
01477     /* Split into language and territory part.  */
01478     primary = PRIMARYLANGID (langid);
01479     sub = SUBLANGID (langid);
01480 
01481     /* Dispatch on language.
01482        See also http://www.unicode.org/unicode/onlinedat/languages.html .
01483        For details about languages, see http://www.ethnologue.com/ .  */
01484     switch (primary)
01485       {
01486       case LANG_AFRIKAANS:
01487         switch (sub)
01488           {
01489           case SUBLANG_AFRIKAANS_SOUTH_AFRICA: return "af_ZA";
01490           }
01491         return "af";
01492       case LANG_ALBANIAN:
01493         switch (sub)
01494           {
01495           case SUBLANG_ALBANIAN_ALBANIA: return "sq_AL";
01496           }
01497         return "sq";
01498       case LANG_ALSATIAN:
01499         switch (sub)
01500           {
01501           case SUBLANG_ALSATIAN_FRANCE: return "gsw_FR";
01502           }
01503         return "gsw";
01504       case LANG_AMHARIC:
01505         switch (sub)
01506           {
01507           case SUBLANG_AMHARIC_ETHIOPIA: return "am_ET";
01508           }
01509         return "am";
01510       case LANG_ARABIC:
01511         switch (sub)
01512           {
01513           case SUBLANG_ARABIC_SAUDI_ARABIA: return "ar_SA";
01514           case SUBLANG_ARABIC_IRAQ: return "ar_IQ";
01515           case SUBLANG_ARABIC_EGYPT: return "ar_EG";
01516           case SUBLANG_ARABIC_LIBYA: return "ar_LY";
01517           case SUBLANG_ARABIC_ALGERIA: return "ar_DZ";
01518           case SUBLANG_ARABIC_MOROCCO: return "ar_MA";
01519           case SUBLANG_ARABIC_TUNISIA: return "ar_TN";
01520           case SUBLANG_ARABIC_OMAN: return "ar_OM";
01521           case SUBLANG_ARABIC_YEMEN: return "ar_YE";
01522           case SUBLANG_ARABIC_SYRIA: return "ar_SY";
01523           case SUBLANG_ARABIC_JORDAN: return "ar_JO";
01524           case SUBLANG_ARABIC_LEBANON: return "ar_LB";
01525           case SUBLANG_ARABIC_KUWAIT: return "ar_KW";
01526           case SUBLANG_ARABIC_UAE: return "ar_AE";
01527           case SUBLANG_ARABIC_BAHRAIN: return "ar_BH";
01528           case SUBLANG_ARABIC_QATAR: return "ar_QA";
01529           }
01530         return "ar";
01531       case LANG_ARMENIAN:
01532         switch (sub)
01533           {
01534           case SUBLANG_ARMENIAN_ARMENIA: return "hy_AM";
01535           }
01536         return "hy";
01537       case LANG_ASSAMESE:
01538         switch (sub)
01539           {
01540           case SUBLANG_ASSAMESE_INDIA: return "as_IN";
01541           }
01542         return "as";
01543       case LANG_AZERI:
01544         switch (sub)
01545           {
01546           /* FIXME: Adjust this when Azerbaijani locales appear on Unix.  */
01547           case 0x1e: return "az@latin";
01548           case SUBLANG_AZERI_LATIN: return "az_AZ@latin";
01549           case 0x1d: return "az@cyrillic";
01550           case SUBLANG_AZERI_CYRILLIC: return "az_AZ@cyrillic";
01551           }
01552         return "az";
01553       case LANG_BASHKIR:
01554         switch (sub)
01555           {
01556           case SUBLANG_BASHKIR_RUSSIA: return "ba_RU";
01557           }
01558         return "ba";
01559       case LANG_BASQUE:
01560         switch (sub)
01561           {
01562           case SUBLANG_BASQUE_BASQUE: return "eu_ES";
01563           }
01564         return "eu"; /* Ambiguous: could be "eu_ES" or "eu_FR".  */
01565       case LANG_BELARUSIAN:
01566         switch (sub)
01567           {
01568           case SUBLANG_BELARUSIAN_BELARUS: return "be_BY";
01569           }
01570         return "be";
01571       case LANG_BENGALI:
01572         switch (sub)
01573           {
01574           case SUBLANG_BENGALI_INDIA: return "bn_IN";
01575           case SUBLANG_BENGALI_BANGLADESH: return "bn_BD";
01576           }
01577         return "bn";
01578       case LANG_BRETON:
01579         switch (sub)
01580           {
01581           case SUBLANG_BRETON_FRANCE: return "br_FR";
01582           }
01583         return "br";
01584       case LANG_BULGARIAN:
01585         switch (sub)
01586           {
01587           case SUBLANG_BULGARIAN_BULGARIA: return "bg_BG";
01588           }
01589         return "bg";
01590       case LANG_BURMESE:
01591         switch (sub)
01592           {
01593           case SUBLANG_DEFAULT: return "my_MM";
01594           }
01595         return "my";
01596       case LANG_CAMBODIAN:
01597         switch (sub)
01598           {
01599           case SUBLANG_CAMBODIAN_CAMBODIA: return "km_KH";
01600           }
01601         return "km";
01602       case LANG_CATALAN:
01603         switch (sub)
01604           {
01605           case SUBLANG_CATALAN_SPAIN: return "ca_ES";
01606           }
01607         return "ca";
01608       case LANG_CHEROKEE:
01609         switch (sub)
01610           {
01611           case SUBLANG_DEFAULT: return "chr_US";
01612           }
01613         return "chr";
01614       case LANG_CHINESE:
01615         switch (sub)
01616           {
01617           case SUBLANG_CHINESE_TRADITIONAL: case 0x1f: return "zh_TW";
01618           case SUBLANG_CHINESE_SIMPLIFIED: case 0x00: return "zh_CN";
01619           case SUBLANG_CHINESE_HONGKONG: return "zh_HK"; /* traditional */
01620           case SUBLANG_CHINESE_SINGAPORE: return "zh_SG"; /* simplified */
01621           case SUBLANG_CHINESE_MACAU: return "zh_MO"; /* traditional */
01622           }
01623         return "zh";
01624       case LANG_CORSICAN:
01625         switch (sub)
01626           {
01627           case SUBLANG_CORSICAN_FRANCE: return "co_FR";
01628           }
01629         return "co";
01630       case LANG_CROATIAN:      /* LANG_CROATIAN == LANG_SERBIAN == LANG_BOSNIAN
01631                                 * What used to be called Serbo-Croatian
01632                                 * should really now be two separate
01633                                 * languages because of political reasons.
01634                                 * (Says tml, who knows nothing about Serbian
01635                                 * or Croatian.)
01636                                 * (I can feel those flames coming already.)
01637                                 */
01638         switch (sub)
01639           {
01640           /* Croatian */
01641           case 0x00: return "hr";
01642           case SUBLANG_CROATIAN_CROATIA: return "hr_HR";
01643           case SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN: return "hr_BA";
01644           /* Serbian */
01645           case 0x1f: return "sr";
01646           case 0x1c: return "sr"; /* latin */
01647           case SUBLANG_SERBIAN_LATIN: return "sr_CS"; /* latin */
01648           case 0x09: return "sr_RS"; /* latin */
01649           case 0x0b: return "sr_ME"; /* latin */
01650           case 0x06: return "sr_BA"; /* latin */
01651           case 0x1b: return "sr@cyrillic";
01652           case SUBLANG_SERBIAN_CYRILLIC: return "sr_CS@cyrillic";
01653           case 0x0a: return "sr_RS@cyrillic";
01654           case 0x0c: return "sr_ME@cyrillic";
01655           case 0x07: return "sr_BA@cyrillic";
01656           /* Bosnian */
01657           case 0x1e: return "bs";
01658           case 0x1a: return "bs"; /* latin */
01659           case SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN: return "bs_BA"; /* latin */
01660           case 0x19: return "bs@cyrillic";
01661           case SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC: return "bs_BA@cyrillic";
01662           }
01663         return "hr";
01664       case LANG_CZECH:
01665         switch (sub)
01666           {
01667           case SUBLANG_CZECH_CZECH_REPUBLIC: return "cs_CZ";
01668           }
01669         return "cs";
01670       case LANG_DANISH:
01671         switch (sub)
01672           {
01673           case SUBLANG_DANISH_DENMARK: return "da_DK";
01674           }
01675         return "da";
01676       case LANG_DARI:
01677         /* FIXME: Adjust this when such locales appear on Unix.  */
01678         switch (sub)
01679           {
01680           case SUBLANG_DARI_AFGHANISTAN: return "prs_AF";
01681           }
01682         return "prs";
01683       case LANG_DIVEHI:
01684         switch (sub)
01685           {
01686           case SUBLANG_DIVEHI_MALDIVES: return "dv_MV";
01687           }
01688         return "dv";
01689       case LANG_DUTCH:
01690         switch (sub)
01691           {
01692           case SUBLANG_DUTCH: return "nl_NL";
01693           case SUBLANG_DUTCH_BELGIAN: /* FLEMISH, VLAAMS */ return "nl_BE";
01694           case SUBLANG_DUTCH_SURINAM: return "nl_SR";
01695           }
01696         return "nl";
01697       case LANG_EDO:
01698         switch (sub)
01699           {
01700           case SUBLANG_DEFAULT: return "bin_NG";
01701           }
01702         return "bin";
01703       case LANG_ENGLISH:
01704         switch (sub)
01705           {
01706           /* SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. Heh. I thought
01707            * English was the language spoken in England.
01708            * Oh well.
01709            */
01710           case SUBLANG_ENGLISH_US: return "en_US";
01711           case SUBLANG_ENGLISH_UK: return "en_GB";
01712           case SUBLANG_ENGLISH_AUS: return "en_AU";
01713           case SUBLANG_ENGLISH_CAN: return "en_CA";
01714           case SUBLANG_ENGLISH_NZ: return "en_NZ";
01715           case SUBLANG_ENGLISH_EIRE: return "en_IE";
01716           case SUBLANG_ENGLISH_SOUTH_AFRICA: return "en_ZA";
01717           case SUBLANG_ENGLISH_JAMAICA: return "en_JM";
01718           case SUBLANG_ENGLISH_CARIBBEAN: return "en_GD"; /* Grenada? */
01719           case SUBLANG_ENGLISH_BELIZE: return "en_BZ";
01720           case SUBLANG_ENGLISH_TRINIDAD: return "en_TT";
01721           case SUBLANG_ENGLISH_ZIMBABWE: return "en_ZW";
01722           case SUBLANG_ENGLISH_PHILIPPINES: return "en_PH";
01723           case SUBLANG_ENGLISH_INDONESIA: return "en_ID";
01724           case SUBLANG_ENGLISH_HONGKONG: return "en_HK";
01725           case SUBLANG_ENGLISH_INDIA: return "en_IN";
01726           case SUBLANG_ENGLISH_MALAYSIA: return "en_MY";
01727           case SUBLANG_ENGLISH_SINGAPORE: return "en_SG";
01728           }
01729         return "en";
01730       case LANG_ESTONIAN:
01731         switch (sub)
01732           {
01733           case SUBLANG_ESTONIAN_ESTONIA: return "et_EE";
01734           }
01735         return "et";
01736       case LANG_FAEROESE:
01737         switch (sub)
01738           {
01739           case SUBLANG_FAEROESE_FAROE_ISLANDS: return "fo_FO";
01740           }
01741         return "fo";
01742       case LANG_FARSI:
01743         switch (sub)
01744           {
01745           case SUBLANG_FARSI_IRAN: return "fa_IR";
01746           }
01747         return "fa";
01748       case LANG_FINNISH:
01749         switch (sub)
01750           {
01751           case SUBLANG_FINNISH_FINLAND: return "fi_FI";
01752           }
01753         return "fi";
01754       case LANG_FRENCH:
01755         switch (sub)
01756           {
01757           case SUBLANG_FRENCH: return "fr_FR";
01758           case SUBLANG_FRENCH_BELGIAN: /* WALLOON */ return "fr_BE";
01759           case SUBLANG_FRENCH_CANADIAN: return "fr_CA";
01760           case SUBLANG_FRENCH_SWISS: return "fr_CH";
01761           case SUBLANG_FRENCH_LUXEMBOURG: return "fr_LU";
01762           case SUBLANG_FRENCH_MONACO: return "fr_MC";
01763           case SUBLANG_FRENCH_WESTINDIES: return "fr"; /* Caribbean? */
01764           case SUBLANG_FRENCH_REUNION: return "fr_RE";
01765           case SUBLANG_FRENCH_CONGO: return "fr_CG";
01766           case SUBLANG_FRENCH_SENEGAL: return "fr_SN";
01767           case SUBLANG_FRENCH_CAMEROON: return "fr_CM";
01768           case SUBLANG_FRENCH_COTEDIVOIRE: return "fr_CI";
01769           case SUBLANG_FRENCH_MALI: return "fr_ML";
01770           case SUBLANG_FRENCH_MOROCCO: return "fr_MA";
01771           case SUBLANG_FRENCH_HAITI: return "fr_HT";
01772           }
01773         return "fr";
01774       case LANG_FRISIAN:
01775         switch (sub)
01776           {
01777           case SUBLANG_FRISIAN_NETHERLANDS: return "fy_NL";
01778           }
01779         return "fy";
01780       case LANG_FULFULDE:
01781         /* Spoken in Nigeria, Guinea, Senegal, Mali, Niger, Cameroon, Benin.  */
01782         switch (sub)
01783           {
01784           case SUBLANG_DEFAULT: return "ff_NG";
01785           }
01786         return "ff";
01787       case LANG_GAELIC:
01788         switch (sub)
01789           {
01790           case 0x01: /* SCOTTISH */
01791             /* old, superseded by LANG_SCOTTISH_GAELIC */
01792             return "gd_GB";
01793           case SUBLANG_IRISH_IRELAND: return "ga_IE";
01794           }
01795         return "ga";
01796       case LANG_GALICIAN:
01797         switch (sub)
01798           {
01799           case SUBLANG_GALICIAN_SPAIN: return "gl_ES";
01800           }
01801         return "gl";
01802       case LANG_GEORGIAN:
01803         switch (sub)
01804           {
01805           case SUBLANG_GEORGIAN_GEORGIA: return "ka_GE";
01806           }
01807         return "ka";
01808       case LANG_GERMAN:
01809         switch (sub)
01810           {
01811           case SUBLANG_GERMAN: return "de_DE";
01812           case SUBLANG_GERMAN_SWISS: return "de_CH";
01813           case SUBLANG_GERMAN_AUSTRIAN: return "de_AT";
01814           case SUBLANG_GERMAN_LUXEMBOURG: return "de_LU";
01815           case SUBLANG_GERMAN_LIECHTENSTEIN: return "de_LI";
01816           }
01817         return "de";
01818       case LANG_GREEK:
01819         switch (sub)
01820           {
01821           case SUBLANG_GREEK_GREECE: return "el_GR";
01822           }
01823         return "el";
01824       case LANG_GREENLANDIC:
01825         switch (sub)
01826           {
01827           case SUBLANG_GREENLANDIC_GREENLAND: return "kl_GL";
01828           }
01829         return "kl";
01830       case LANG_GUARANI:
01831         switch (sub)
01832           {
01833           case SUBLANG_DEFAULT: return "gn_PY";
01834           }
01835         return "gn";
01836       case LANG_GUJARATI:
01837         switch (sub)
01838           {
01839           case SUBLANG_GUJARATI_INDIA: return "gu_IN";
01840           }
01841         return "gu";
01842       case LANG_HAUSA:
01843         switch (sub)
01844           {
01845           case 0x1f: return "ha";
01846           case SUBLANG_HAUSA_NIGERIA_LATIN: return "ha_NG";
01847           }
01848         return "ha";
01849       case LANG_HAWAIIAN:
01850         /* FIXME: Do they mean Hawaiian ("haw_US", 1000 speakers)
01851            or Hawaii Creole English ("cpe_US", 600000 speakers)?  */
01852         switch (sub)
01853           {
01854           case SUBLANG_DEFAULT: return "cpe_US";
01855           }
01856         return "cpe";
01857       case LANG_HEBREW:
01858         switch (sub)
01859           {
01860           case SUBLANG_HEBREW_ISRAEL: return "he_IL";
01861           }
01862         return "he";
01863       case LANG_HINDI:
01864         switch (sub)
01865           {
01866           case SUBLANG_HINDI_INDIA: return "hi_IN";
01867           }
01868         return "hi";
01869       case LANG_HUNGARIAN:
01870         switch (sub)
01871           {
01872           case SUBLANG_HUNGARIAN_HUNGARY: return "hu_HU";
01873           }
01874         return "hu";
01875       case LANG_IBIBIO:
01876         switch (sub)
01877           {
01878           case SUBLANG_DEFAULT: return "nic_NG";
01879           }
01880         return "nic";
01881       case LANG_ICELANDIC:
01882         switch (sub)
01883           {
01884           case SUBLANG_ICELANDIC_ICELAND: return "is_IS";
01885           }
01886         return "is";
01887       case LANG_IGBO:
01888         switch (sub)
01889           {
01890           case SUBLANG_IGBO_NIGERIA: return "ig_NG";
01891           }
01892         return "ig";
01893       case LANG_INDONESIAN:
01894         switch (sub)
01895           {
01896           case SUBLANG_INDONESIAN_INDONESIA: return "id_ID";
01897           }
01898         return "id";
01899       case LANG_INUKTITUT:
01900         switch (sub)
01901           {
01902           case 0x1e: return "iu"; /* syllabic */
01903           case SUBLANG_INUKTITUT_CANADA: return "iu_CA"; /* syllabic */
01904           case 0x1f: return "iu@latin";
01905           case SUBLANG_INUKTITUT_CANADA_LATIN: return "iu_CA@latin";
01906           }
01907         return "iu";
01908       case LANG_ITALIAN:
01909         switch (sub)
01910           {
01911           case SUBLANG_ITALIAN: return "it_IT";
01912           case SUBLANG_ITALIAN_SWISS: return "it_CH";
01913           }
01914         return "it";
01915       case LANG_JAPANESE:
01916         switch (sub)
01917           {
01918           case SUBLANG_JAPANESE_JAPAN: return "ja_JP";
01919           }
01920         return "ja";
01921       case LANG_KANNADA:
01922         switch (sub)
01923           {
01924           case SUBLANG_KANNADA_INDIA: return "kn_IN";
01925           }
01926         return "kn";
01927       case LANG_KANURI:
01928         switch (sub)
01929           {
01930           case SUBLANG_DEFAULT: return "kr_NG";
01931           }
01932         return "kr";
01933       case LANG_KASHMIRI:
01934         switch (sub)
01935           {
01936           case SUBLANG_DEFAULT: return "ks_PK";
01937           case SUBLANG_KASHMIRI_INDIA: return "ks_IN";
01938           }
01939         return "ks";
01940       case LANG_KAZAK:
01941         switch (sub)
01942           {
01943           case SUBLANG_KAZAK_KAZAKHSTAN: return "kk_KZ";
01944           }
01945         return "kk";
01946       case LANG_KICHE:
01947         /* FIXME: Adjust this when such locales appear on Unix.  */
01948         switch (sub)
01949           {
01950           case SUBLANG_KICHE_GUATEMALA: return "qut_GT";
01951           }
01952         return "qut";
01953       case LANG_KINYARWANDA:
01954         switch (sub)
01955           {
01956           case SUBLANG_KINYARWANDA_RWANDA: return "rw_RW";
01957           }
01958         return "rw";
01959       case LANG_KONKANI:
01960         /* FIXME: Adjust this when such locales appear on Unix.  */
01961         switch (sub)
01962           {
01963           case SUBLANG_KONKANI_INDIA: return "kok_IN";
01964           }
01965         return "kok";
01966       case LANG_KOREAN:
01967         switch (sub)
01968           {
01969           case SUBLANG_DEFAULT: return "ko_KR";
01970           }
01971         return "ko";
01972       case LANG_KYRGYZ:
01973         switch (sub)
01974           {
01975           case SUBLANG_KYRGYZ_KYRGYZSTAN: return "ky_KG";
01976           }
01977         return "ky";
01978       case LANG_LAO:
01979         switch (sub)
01980           {
01981           case SUBLANG_LAO_LAOS: return "lo_LA";
01982           }
01983         return "lo";
01984       case LANG_LATIN:
01985         switch (sub)
01986           {
01987           case SUBLANG_DEFAULT: return "la_VA";
01988           }
01989         return "la";
01990       case LANG_LATVIAN:
01991         switch (sub)
01992           {
01993           case SUBLANG_LATVIAN_LATVIA: return "lv_LV";
01994           }
01995         return "lv";
01996       case LANG_LITHUANIAN:
01997         switch (sub)
01998           {
01999           case SUBLANG_LITHUANIAN_LITHUANIA: return "lt_LT";
02000           }
02001         return "lt";
02002       case LANG_LUXEMBOURGISH:
02003         switch (sub)
02004           {
02005           case SUBLANG_LUXEMBOURGISH_LUXEMBOURG: return "lb_LU";
02006           }
02007         return "lb";
02008       case LANG_MACEDONIAN:
02009         switch (sub)
02010           {
02011           case SUBLANG_MACEDONIAN_MACEDONIA: return "mk_MK";
02012           }
02013         return "mk";
02014       case LANG_MALAY:
02015         switch (sub)
02016           {
02017           case SUBLANG_MALAY_MALAYSIA: return "ms_MY";
02018           case SUBLANG_MALAY_BRUNEI_DARUSSALAM: return "ms_BN";
02019           }
02020         return "ms";
02021       case LANG_MALAYALAM:
02022         switch (sub)
02023           {
02024           case SUBLANG_MALAYALAM_INDIA: return "ml_IN";
02025           }
02026         return "ml";
02027       case LANG_MALTESE:
02028         switch (sub)
02029           {
02030           case SUBLANG_MALTESE_MALTA: return "mt_MT";
02031           }
02032         return "mt";
02033       case LANG_MANIPURI:
02034         /* FIXME: Adjust this when such locales appear on Unix.  */
02035         switch (sub)
02036           {
02037           case SUBLANG_DEFAULT: return "mni_IN";
02038           }
02039         return "mni";
02040       case LANG_MAORI:
02041         switch (sub)
02042           {
02043           case SUBLANG_MAORI_NEW_ZEALAND: return "mi_NZ";
02044           }
02045         return "mi";
02046       case LANG_MAPUDUNGUN:
02047         switch (sub)
02048           {
02049           case SUBLANG_MAPUDUNGUN_CHILE: return "arn_CL";
02050           }
02051         return "arn";
02052       case LANG_MARATHI:
02053         switch (sub)
02054           {
02055           case SUBLANG_MARATHI_INDIA: return "mr_IN";
02056           }
02057         return "mr";
02058       case LANG_MOHAWK:
02059         switch (sub)
02060           {
02061           case SUBLANG_MOHAWK_CANADA: return "moh_CA";
02062           }
02063         return "moh";
02064       case LANG_MONGOLIAN:
02065         switch (sub)
02066           {
02067           case SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA: case 0x1e: return "mn_MN";
02068           case SUBLANG_MONGOLIAN_PRC: case 0x1f: return "mn_CN";
02069           }
02070         return "mn"; /* Ambiguous: could be "mn_CN" or "mn_MN".  */
02071       case LANG_NEPALI:
02072         switch (sub)
02073           {
02074           case SUBLANG_NEPALI_NEPAL: return "ne_NP";
02075           case SUBLANG_NEPALI_INDIA: return "ne_IN";
02076           }
02077         return "ne";
02078       case LANG_NORWEGIAN:
02079         switch (sub)
02080           {
02081           case 0x1f: return "nb";
02082           case SUBLANG_NORWEGIAN_BOKMAL: return "nb_NO";
02083           case 0x1e: return "nn";
02084           case SUBLANG_NORWEGIAN_NYNORSK: return "nn_NO";
02085           }
02086         return "no";
02087       case LANG_OCCITAN:
02088         switch (sub)
02089           {
02090           case SUBLANG_OCCITAN_FRANCE: return "oc_FR";
02091           }
02092         return "oc";
02093       case LANG_ORIYA:
02094         switch (sub)
02095           {
02096           case SUBLANG_ORIYA_INDIA: return "or_IN";
02097           }
02098         return "or";
02099       case LANG_OROMO:
02100         switch (sub)
02101           {
02102           case SUBLANG_DEFAULT: return "om_ET";
02103           }
02104         return "om";
02105       case LANG_PAPIAMENTU:
02106         switch (sub)
02107           {
02108           case SUBLANG_DEFAULT: return "pap_AN";
02109           }
02110         return "pap";
02111       case LANG_PASHTO:
02112         switch (sub)
02113           {
02114           case SUBLANG_PASHTO_AFGHANISTAN: return "ps_AF";
02115           }
02116         return "ps"; /* Ambiguous: could be "ps_PK" or "ps_AF".  */
02117       case LANG_POLISH:
02118         switch (sub)
02119           {
02120           case SUBLANG_POLISH_POLAND: return "pl_PL";
02121           }
02122         return "pl";
02123       case LANG_PORTUGUESE:
02124         switch (sub)
02125           {
02126           /* Hmm. SUBLANG_PORTUGUESE_BRAZILIAN == SUBLANG_DEFAULT.
02127              Same phenomenon as SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. */
02128           case SUBLANG_PORTUGUESE_BRAZILIAN: return "pt_BR";
02129           case SUBLANG_PORTUGUESE: return "pt_PT";
02130           }
02131         return "pt";
02132       case LANG_PUNJABI:
02133         switch (sub)
02134           {
02135           case SUBLANG_PUNJABI_INDIA: return "pa_IN"; /* Gurmukhi script */
02136           case SUBLANG_PUNJABI_PAKISTAN: return "pa_PK"; /* Arabic script */
02137           }
02138         return "pa";
02139       case LANG_QUECHUA:
02140         /* Note: Microsoft uses the non-ISO language code "quz".  */
02141         switch (sub)
02142           {
02143           case SUBLANG_QUECHUA_BOLIVIA: return "qu_BO";
02144           case SUBLANG_QUECHUA_ECUADOR: return "qu_EC";
02145           case SUBLANG_QUECHUA_PERU: return "qu_PE";
02146           }
02147         return "qu";
02148       case LANG_ROMANIAN:
02149         switch (sub)
02150           {
02151           case SUBLANG_ROMANIAN_ROMANIA: return "ro_RO";
02152           case SUBLANG_ROMANIAN_MOLDOVA: return "ro_MD";
02153           }
02154         return "ro";
02155       case LANG_ROMANSH:
02156         switch (sub)
02157           {
02158           case SUBLANG_ROMANSH_SWITZERLAND: return "rm_CH";
02159           }
02160         return "rm";
02161       case LANG_RUSSIAN:
02162         switch (sub)
02163           {
02164           case SUBLANG_RUSSIAN_RUSSIA: return "ru_RU";
02165           case SUBLANG_RUSSIAN_MOLDAVIA: return "ru_MD";
02166           }
02167         return "ru"; /* Ambiguous: could be "ru_RU" or "ru_UA" or "ru_MD".  */
02168       case LANG_SAMI:
02169         switch (sub)
02170           {
02171           /* Northern Sami */
02172           case 0x00: return "se";
02173           case SUBLANG_SAMI_NORTHERN_NORWAY: return "se_NO";
02174           case SUBLANG_SAMI_NORTHERN_SWEDEN: return "se_SE";
02175           case SUBLANG_SAMI_NORTHERN_FINLAND: return "se_FI";
02176           /* Lule Sami */
02177           case 0x1f: return "smj";
02178           case SUBLANG_SAMI_LULE_NORWAY: return "smj_NO";
02179           case SUBLANG_SAMI_LULE_SWEDEN: return "smj_SE";
02180           /* Southern Sami */
02181           case 0x1e: return "sma";
02182           case SUBLANG_SAMI_SOUTHERN_NORWAY: return "sma_NO";
02183           case SUBLANG_SAMI_SOUTHERN_SWEDEN: return "sma_SE";
02184           /* Skolt Sami */
02185           case 0x1d: return "sms";
02186           case SUBLANG_SAMI_SKOLT_FINLAND: return "sms_FI";
02187           /* Inari Sami */
02188           case 0x1c: return "smn";
02189           case SUBLANG_SAMI_INARI_FINLAND: return "smn_FI";
02190           }
02191         return "se"; /* or "smi"? */
02192       case LANG_SANSKRIT:
02193         switch (sub)
02194           {
02195           case SUBLANG_SANSKRIT_INDIA: return "sa_IN";
02196           }
02197         return "sa";
02198       case LANG_SCOTTISH_GAELIC:
02199         switch (sub)
02200           {
02201           case SUBLANG_DEFAULT: return "gd_GB";
02202           }
02203         return "gd";
02204       case LANG_SINDHI:
02205         switch (sub)
02206           {
02207           case SUBLANG_SINDHI_INDIA: return "sd_IN";
02208           case SUBLANG_SINDHI_PAKISTAN: return "sd_PK";
02209           /*case SUBLANG_SINDHI_AFGHANISTAN: return "sd_AF";*/
02210           }
02211         return "sd";
02212       case LANG_SINHALESE:
02213         switch (sub)
02214           {
02215           case SUBLANG_SINHALESE_SRI_LANKA: return "si_LK";
02216           }
02217         return "si";
02218       case LANG_SLOVAK:
02219         switch (sub)
02220           {
02221           case SUBLANG_SLOVAK_SLOVAKIA: return "sk_SK";
02222           }
02223         return "sk";
02224       case LANG_SLOVENIAN:
02225         switch (sub)
02226           {
02227           case SUBLANG_SLOVENIAN_SLOVENIA: return "sl_SI";
02228           }
02229         return "sl";
02230       case LANG_SOMALI:
02231         switch (sub)
02232           {
02233           case SUBLANG_DEFAULT: return "so_SO";
02234           }
02235         return "so";
02236       case LANG_SORBIAN:
02237         /* FIXME: Adjust this when such locales appear on Unix.  */
02238         switch (sub)
02239           {
02240           /* Upper Sorbian */
02241           case 0x00: return "hsb";
02242           case SUBLANG_UPPER_SORBIAN_GERMANY: return "hsb_DE";
02243           /* Lower Sorbian */
02244           case 0x1f: return "dsb";
02245           case SUBLANG_LOWER_SORBIAN_GERMANY: return "dsb_DE";
02246           }
02247         return "wen";
02248       case LANG_SOTHO:
02249         /* <http://www.microsoft.com/globaldev/reference/lcid-all.mspx> calls
02250            it "Sepedi"; according to
02251            <http://www.ethnologue.com/show_language.asp?code=nso>
02252            <http://www.ethnologue.com/show_language.asp?code=sot>
02253            it's the same as Northern Sotho.  */
02254         switch (sub)
02255           {
02256           case SUBLANG_SOTHO_SOUTH_AFRICA: return "nso_ZA";
02257           }
02258         return "nso";
02259       case LANG_SPANISH:
02260         switch (sub)
02261           {
02262           case SUBLANG_SPANISH: return "es_ES";
02263           case SUBLANG_SPANISH_MEXICAN: return "es_MX";
02264           case SUBLANG_SPANISH_MODERN:
02265             return "es_ES@modern";      /* not seen on Unix */
02266           case SUBLANG_SPANISH_GUATEMALA: return "es_GT";
02267           case SUBLANG_SPANISH_COSTA_RICA: return "es_CR";
02268           case SUBLANG_SPANISH_PANAMA: return "es_PA";
02269           case SUBLANG_SPANISH_DOMINICAN_REPUBLIC: return "es_DO";
02270           case SUBLANG_SPANISH_VENEZUELA: return "es_VE";
02271           case SUBLANG_SPANISH_COLOMBIA: return "es_CO";
02272           case SUBLANG_SPANISH_PERU: return "es_PE";
02273           case SUBLANG_SPANISH_ARGENTINA: return "es_AR";
02274           case SUBLANG_SPANISH_ECUADOR: return "es_EC";
02275           case SUBLANG_SPANISH_CHILE: return "es_CL";
02276           case SUBLANG_SPANISH_URUGUAY: return "es_UY";
02277           case SUBLANG_SPANISH_PARAGUAY: return "es_PY";
02278           case SUBLANG_SPANISH_BOLIVIA: return "es_BO";
02279           case SUBLANG_SPANISH_EL_SALVADOR: return "es_SV";
02280           case SUBLANG_SPANISH_HONDURAS: return "es_HN";
02281           case SUBLANG_SPANISH_NICARAGUA: return "es_NI";
02282           case SUBLANG_SPANISH_PUERTO_RICO: return "es_PR";
02283           case SUBLANG_SPANISH_US: return "es_US";
02284           }
02285         return "es";
02286       case LANG_SUTU:
02287         switch (sub)
02288           {
02289           case SUBLANG_DEFAULT: return "bnt_TZ"; /* or "st_LS" or "nso_ZA"? */
02290           }
02291         return "bnt";
02292       case LANG_SWAHILI:
02293         switch (sub)
02294           {
02295           case SUBLANG_SWAHILI_KENYA: return "sw_KE";
02296           }
02297         return "sw";
02298       case LANG_SWEDISH:
02299         switch (sub)
02300           {
02301           case SUBLANG_SWEDISH_SWEDEN: return "sv_SE";
02302           case SUBLANG_SWEDISH_FINLAND: return "sv_FI";
02303           }
02304         return "sv";
02305       case LANG_SYRIAC:
02306         switch (sub)
02307           {
02308           case SUBLANG_SYRIAC_SYRIA: return "syr_SY"; /* An extinct language.  */
02309           }
02310         return "syr";
02311       case LANG_TAGALOG:
02312         switch (sub)
02313           {
02314           case SUBLANG_TAGALOG_PHILIPPINES: return "tl_PH"; /* or "fil_PH"? */
02315           }
02316         return "tl"; /* or "fil"? */
02317       case LANG_TAJIK:
02318         switch (sub)
02319           {
02320           case 0x1f: return "tg";
02321           case SUBLANG_TAJIK_TAJIKISTAN: return "tg_TJ";
02322           }
02323         return "tg";
02324       case LANG_TAMAZIGHT:
02325         /* Note: Microsoft uses the non-ISO language code "tmz".  */
02326         switch (sub)
02327           {
02328           /* FIXME: Adjust this when Tamazight locales appear on Unix.  */
02329           case SUBLANG_TAMAZIGHT_ARABIC: return "ber_MA@arabic";
02330           case 0x1f: return "ber@latin";
02331           case SUBLANG_TAMAZIGHT_ALGERIA_LATIN: return "ber_DZ@latin";
02332           }
02333         return "ber";
02334       case LANG_TAMIL:
02335         switch (sub)
02336           {
02337           case SUBLANG_TAMIL_INDIA: return "ta_IN";
02338           }
02339         return "ta"; /* Ambiguous: could be "ta_IN" or "ta_LK" or "ta_SG".  */
02340       case LANG_TATAR:
02341         switch (sub)
02342           {
02343           case SUBLANG_TATAR_RUSSIA: return "tt_RU";
02344           }
02345         return "tt";
02346       case LANG_TELUGU:
02347         switch (sub)
02348           {
02349           case SUBLANG_TELUGU_INDIA: return "te_IN";
02350           }
02351         return "te";
02352       case LANG_THAI:
02353         switch (sub)
02354           {
02355           case SUBLANG_THAI_THAILAND: return "th_TH";
02356           }
02357         return "th";
02358       case LANG_TIBETAN:
02359         switch (sub)
02360           {
02361           case SUBLANG_TIBETAN_PRC:
02362             /* Most Tibetans would not like "bo_CN".  But Tibet does not yet
02363                have a country code of its own.  */
02364             return "bo";
02365           case SUBLANG_TIBETAN_BHUTAN: return "bo_BT";
02366           }
02367         return "bo";
02368       case LANG_TIGRINYA:
02369         switch (sub)
02370           {
02371           case SUBLANG_TIGRINYA_ETHIOPIA: return "ti_ET";
02372           case SUBLANG_TIGRINYA_ERITREA: return "ti_ER";
02373           }
02374         return "ti";
02375       case LANG_TSONGA:
02376         switch (sub)
02377           {
02378           case SUBLANG_DEFAULT: return "ts_ZA";
02379           }
02380         return "ts";
02381       case LANG_TSWANA:
02382         /* Spoken in South Africa, Botswana.  */
02383         switch (sub)
02384           {
02385           case SUBLANG_TSWANA_SOUTH_AFRICA: return "tn_ZA";
02386           }
02387         return "tn";
02388       case LANG_TURKISH:
02389         switch (sub)
02390           {
02391           case SUBLANG_TURKISH_TURKEY: return "tr_TR";
02392           }
02393         return "tr";
02394       case LANG_TURKMEN:
02395         switch (sub)
02396           {
02397           case SUBLANG_TURKMEN_TURKMENISTAN: return "tk_TM";
02398           }
02399         return "tk";
02400       case LANG_UIGHUR:
02401         switch (sub)
02402           {
02403           case SUBLANG_UIGHUR_PRC: return "ug_CN";
02404           }
02405         return "ug";
02406       case LANG_UKRAINIAN:
02407         switch (sub)
02408           {
02409           case SUBLANG_UKRAINIAN_UKRAINE: return "uk_UA";
02410           }
02411         return "uk";
02412       case LANG_URDU:
02413         switch (sub)
02414           {
02415           case SUBLANG_URDU_PAKISTAN: return "ur_PK";
02416           case SUBLANG_URDU_INDIA: return "ur_IN";
02417           }
02418         return "ur";
02419       case LANG_UZBEK:
02420         switch (sub)
02421           {
02422           case 0x1f: return "uz";
02423           case SUBLANG_UZBEK_LATIN: return "uz_UZ";
02424           case 0x1e: return "uz@cyrillic";
02425           case SUBLANG_UZBEK_CYRILLIC: return "uz_UZ@cyrillic";
02426           }
02427         return "uz";
02428       case LANG_VENDA:
02429         switch (sub)
02430           {
02431           case SUBLANG_DEFAULT: return "ve_ZA";
02432           }
02433         return "ve";
02434       case LANG_VIETNAMESE:
02435         switch (sub)
02436           {
02437           case SUBLANG_VIETNAMESE_VIETNAM: return "vi_VN";
02438           }
02439         return "vi";
02440       case LANG_WELSH:
02441         switch (sub)
02442           {
02443           case SUBLANG_WELSH_UNITED_KINGDOM: return "cy_GB";
02444           }
02445         return "cy";
02446       case LANG_WOLOF:
02447         switch (sub)
02448           {
02449           case SUBLANG_WOLOF_SENEGAL: return "wo_SN";
02450           }
02451         return "wo";
02452       case LANG_XHOSA:
02453         switch (sub)
02454           {
02455           case SUBLANG_XHOSA_SOUTH_AFRICA: return "xh_ZA";
02456           }
02457         return "xh";
02458       case LANG_YAKUT:
02459         switch (sub)
02460           {
02461           case SUBLANG_YAKUT_RUSSIA: return "sah_RU";
02462           }
02463         return "sah";
02464       case LANG_YI:
02465         switch (sub)
02466           {
02467           case SUBLANG_YI_PRC: return "ii_CN";
02468           }
02469         return "ii";
02470       case LANG_YIDDISH:
02471         switch (sub)
02472           {
02473           case SUBLANG_DEFAULT: return "yi_IL";
02474           }
02475         return "yi";
02476       case LANG_YORUBA:
02477         switch (sub)
02478           {
02479           case SUBLANG_YORUBA_NIGERIA: return "yo_NG";
02480           }
02481         return "yo";
02482       case LANG_ZULU:
02483         switch (sub)
02484           {
02485           case SUBLANG_ZULU_SOUTH_AFRICA: return "zu_ZA";
02486           }
02487         return "zu";
02488       default: return "C";
02489       }
02490   }
02491 }
02492 
02493 # if !defined IN_LIBINTL
02494 static
02495 # endif
02496 const char *
02497 gl_locale_name_from_win32_LCID (LCID lcid)
02498 {
02499   LANGID langid;
02500 
02501   /* Strip off the sorting rules, keep only the language part.  */
02502   langid = LANGIDFROMLCID (lcid);
02503 
02504   return gl_locale_name_from_win32_LANGID (langid);
02505 }
02506 
02507 #endif
02508 
02509 
02510 #if HAVE_USELOCALE /* glibc or MacOS X */
02511 
02512 /* Simple hash set of strings.  We don't want to drag in lots of hash table
02513    code here.  */
02514 
02515 # define SIZE_BITS (sizeof (size_t) * CHAR_BIT)
02516 
02517 /* A hash function for NUL-terminated char* strings using
02518    the method described by Bruno Haible.
02519    See http://www.haible.de/bruno/hashfunc.html.  */
02520 static size_t
02521 string_hash (const void *x)
02522 {
02523   const char *s = (const char *) x;
02524   size_t h = 0;
02525 
02526   for (; *s; s++)
02527     h = *s + ((h << 9) | (h >> (SIZE_BITS - 9)));
02528 
02529   return h;
02530 }
02531 
02532 /* A hash table of fixed size.  Multiple threads can access it read-only
02533    simultaneously, but only one thread can insert into it at the same time.  */
02534 
02535 /* A node in a hash bucket collision list.  */
02536 struct hash_node
02537   {
02538     struct hash_node * volatile next;
02539     char contents[100]; /* has variable size */
02540   };
02541 
02542 # define HASH_TABLE_SIZE 257
02543 static struct hash_node * volatile struniq_hash_table[HASH_TABLE_SIZE]
02544   /* = { NULL, ..., NULL } */;
02545 
02546 /* This lock protects the struniq_hash_table against multiple simultaneous
02547    insertions.  */
02548 gl_lock_define_initialized(static, struniq_lock)
02549 
02550 /* Store a copy of the given string in a string pool with indefinite extent.
02551    Return a pointer to this copy.  */
02552 static const char *
02553 struniq (const char *string)
02554 {
02555   size_t hashcode = string_hash (string);
02556   size_t slot = hashcode % HASH_TABLE_SIZE;
02557   size_t size;
02558   struct hash_node *new_node;
02559   struct hash_node *p;
02560   for (p = struniq_hash_table[slot]; p != NULL; p = p->next)
02561     if (strcmp (p->contents, string) == 0)
02562       return p->contents;
02563   size = strlen (string) + 1;
02564   new_node =
02565     (struct hash_node *)
02566     malloc (offsetof (struct hash_node, contents[0]) + size);
02567   if (new_node == NULL)
02568     /* Out of memory.  Return a statically allocated string.  */
02569     return "C";
02570   memcpy (new_node->contents, string, size);
02571   /* Lock while inserting new_node.  */
02572   gl_lock_lock (struniq_lock);
02573   /* Check whether another thread already added the string while we were
02574      waiting on the lock.  */
02575   for (p = struniq_hash_table[slot]; p != NULL; p = p->next)
02576     if (strcmp (p->contents, string) == 0)
02577       {
02578         free (new_node);
02579         new_node = p;
02580         goto done;
02581       }
02582   /* Really insert new_node into the hash table.  Fill new_node entirely first,
02583      because other threads may be iterating over the linked list.  */
02584   new_node->next = struniq_hash_table[slot];
02585   struniq_hash_table[slot] = new_node;
02586  done:
02587   /* Unlock after new_node is inserted.  */
02588   gl_lock_unlock (struniq_lock);
02589   return new_node->contents;
02590 }
02591 
02592 #endif
02593 
02594 
02595 #if defined IN_LIBINTL || HAVE_USELOCALE
02596 
02597 /* Like gl_locale_name_thread, except that the result is not in storage of
02598    indefinite extent.  */
02599 # if !defined IN_LIBINTL
02600 static
02601 # endif
02602 const char *
02603 gl_locale_name_thread_unsafe (int category, const char *categoryname)
02604 {
02605 # if HAVE_USELOCALE
02606   {
02607     locale_t thread_locale = uselocale (NULL);
02608     if (thread_locale != LC_GLOBAL_LOCALE)
02609       {
02610 #  if __GLIBC__ >= 2
02611         /* Work around an incorrect definition of the _NL_LOCALE_NAME macro in
02612            glibc < 2.12.
02613            See <http://sourceware.org/bugzilla/show_bug.cgi?id=10968>.  */
02614         const char *name =
02615           nl_langinfo (_NL_ITEM ((category), _NL_ITEM_INDEX (-1)));
02616         if (name[0] == '\0')
02617           /* Fallback code for glibc < 2.4, which did not implement
02618              nl_langinfo (_NL_LOCALE_NAME (category)).  */
02619           name = thread_locale->__names[category];
02620         return name;
02621 #  endif
02622 #  if defined __APPLE__ && defined __MACH__ /* MacOS X */
02623         /* The locale name is found deep in an undocumented data structure.
02624            Since it's stored in a buffer of size 32 and newlocale() rejects
02625            locale names of length > 31, we can assume that it is NUL terminated
02626            in this buffer. But we need to make a copy of the locale name, of
02627            indefinite extent.  */
02628         struct _xlocale_part1_v0 /* used in MacOS X 10.5 */
02629           {
02630             int32_t __refcount;
02631             void (*__free_extra)(void *);
02632             __darwin_mbstate_t __mbs[10];
02633             int64_t __magic;
02634           };
02635         struct _xlocale_part1_v1 /* used in MacOS X >= 10.6.0 */
02636           {
02637             int32_t __refcount;
02638             void (*__free_extra)(void *);
02639             __darwin_mbstate_t __mbs[10];
02640             /*pthread_lock_t*/ int __lock;
02641             int64_t __magic;
02642           };
02643         struct _xlocale_part2
02644           {
02645             int64_t __magic;
02646             unsigned char __collate_load_error;
02647             unsigned char __collate_substitute_nontrivial;
02648             unsigned char _messages_using_locale;
02649             unsigned char _monetary_using_locale;
02650             unsigned char _numeric_using_locale;
02651             unsigned char _time_using_locale;
02652             unsigned char __mlocale_changed;
02653             unsigned char __nlocale_changed;
02654             unsigned char __numeric_fp_cvt;
02655             struct __xlocale_st_collate *__lc_collate;
02656             struct __xlocale_st_runelocale *__lc_ctype;
02657             struct __xlocale_st_messages *__lc_messages;
02658             struct __xlocale_st_monetary *__lc_monetary;
02659             struct __xlocale_st_numeric *__lc_numeric;
02660             struct _xlocale *__lc_numeric_loc;
02661             struct __xlocale_st_time *__lc_time;
02662             /* more */
02663           };
02664         struct __xlocale_st_collate
02665           {
02666             int32_t __refcount;
02667             void (*__free_extra)(void *);
02668             char __encoding[32];
02669             /* more */
02670           };
02671         struct __xlocale_st_runelocale
02672           {
02673             int32_t __refcount;
02674             void (*__free_extra)(void *);
02675             char __ctype_encoding[32];
02676             /* more */
02677           };
02678         struct __xlocale_st_messages
02679           {
02680             int32_t __refcount;
02681             void (*__free_extra)(void *);
02682             char *_messages_locale_buf;
02683             /* more */
02684           };
02685         struct __xlocale_st_monetary
02686           {
02687             int32_t __refcount;
02688             void (*__free_extra)(void *);
02689             char *_monetary_locale_buf;
02690             /* more */
02691           };
02692         struct __xlocale_st_numeric {
02693             int32_t __refcount;
02694             void (*__free_extra)(void *);
02695             char *_numeric_locale_buf;
02696             /* more */
02697           };
02698         struct __xlocale_st_time {
02699             int32_t __refcount;
02700             void (*__free_extra)(void *);
02701             char *_time_locale_buf;
02702             /* more */
02703           };
02704         struct _xlocale_part2 *tlp;
02705         if (((struct _xlocale_part1_v0 *) thread_locale)->__magic
02706             == 0x786C6F63616C6530LL)
02707           /* MacOS X 10.5 */
02708           tlp =
02709             (struct _xlocale_part2 *)
02710             &((struct _xlocale_part1_v0 *) thread_locale)->__magic;
02711         else if (((struct _xlocale_part1_v1 *) thread_locale)->__magic
02712                  == 0x786C6F63616C6530LL)
02713           /* MacOS X >= 10.6.0 */
02714           tlp =
02715             (struct _xlocale_part2 *)
02716             &((struct _xlocale_part1_v1 *) thread_locale)->__magic;
02717         else
02718           /* Unsupported version of MacOS X: The internals of 'struct _xlocale'
02719              have changed again.  */
02720           return "";
02721         switch (category)
02722           {
02723           case LC_CTYPE:
02724             return tlp->__lc_ctype->__ctype_encoding;
02725           case LC_NUMERIC:
02726             return tlp->_numeric_using_locale
02727                    ? tlp->__lc_numeric->_numeric_locale_buf
02728                    : "C";
02729           case LC_TIME:
02730             return tlp->_time_using_locale
02731                    ? tlp->__lc_time->_time_locale_buf
02732                    : "C";
02733           case LC_COLLATE:
02734             return !tlp->__collate_load_error
02735                    ? tlp->__lc_collate->__encoding
02736                    : "C";
02737           case LC_MONETARY:
02738             return tlp->_monetary_using_locale
02739                    ? tlp->__lc_monetary->_monetary_locale_buf
02740                    : "C";
02741           case LC_MESSAGES:
02742             return tlp->_messages_using_locale
02743                    ? tlp->__lc_messages->_messages_locale_buf
02744                    : "C";
02745           default: /* We shouldn't get here.  */
02746             return "";
02747           }
02748 #  endif
02749       }
02750   }
02751 # endif
02752   return NULL;
02753 }
02754 
02755 #endif
02756 
02757 const char *
02758 gl_locale_name_thread (int category, const char *categoryname)
02759 {
02760 #if HAVE_USELOCALE
02761   const char *name = gl_locale_name_thread_unsafe (category, categoryname);
02762   if (name != NULL)
02763     return struniq (name);
02764 #endif
02765   return NULL;
02766 }
02767 
02768 /* XPG3 defines the result of 'setlocale (category, NULL)' as:
02769    "Directs 'setlocale()' to query 'category' and return the current
02770     setting of 'local'."
02771    However it does not specify the exact format.  Neither do SUSV2 and
02772    ISO C 99.  So we can use this feature only on selected systems (e.g.
02773    those using GNU C Library).  */
02774 #if defined _LIBC || (defined __GLIBC__ && __GLIBC__ >= 2)
02775 # define HAVE_LOCALE_NULL
02776 #endif
02777 
02778 const char *
02779 gl_locale_name_posix (int category, const char *categoryname)
02780 {
02781   /* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'.
02782      On some systems this can be done by the 'setlocale' function itself.  */
02783 #if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
02784   return setlocale (category, NULL);
02785 #else
02786   /* On other systems we ignore what setlocale reports and instead look at the
02787      environment variables directly.  This is necessary
02788        1. on systems which have a facility for customizing the default locale
02789           (MacOS X, native Windows, Cygwin) and where the system's setlocale()
02790           function ignores this default locale (MacOS X, Cygwin), in two cases:
02791           a. when the user missed to use the setlocale() override from libintl
02792              (for example by not including <libintl.h>),
02793           b. when setlocale supports only the "C" locale, such as on Cygwin
02794              1.5.x.  In this case even the override from libintl cannot help.
02795        2. on all systems where setlocale supports only the "C" locale.  */
02796   /* Strictly speaking, it is a POSIX violation to look at the environment
02797      variables regardless whether setlocale has been called or not.  POSIX
02798      says:
02799          "For C-language programs, the POSIX locale shall be the
02800           default locale when the setlocale() function is not called."
02801      But we assume that all programs that use internationalized APIs call
02802      setlocale (LC_ALL, "").  */
02803   return gl_locale_name_environ (category, categoryname);
02804 #endif
02805 }
02806 
02807 const char *
02808 gl_locale_name_environ (int category, const char *categoryname)
02809 {
02810   const char *retval;
02811 
02812   /* Setting of LC_ALL overrides all other.  */
02813   retval = getenv ("LC_ALL");
02814   if (retval != NULL && retval[0] != '\0')
02815     return retval;
02816   /* Next comes the name of the desired category.  */
02817   retval = getenv (categoryname);
02818   if (retval != NULL && retval[0] != '\0')
02819     return retval;
02820   /* Last possibility is the LANG environment variable.  */
02821   retval = getenv ("LANG");
02822   if (retval != NULL && retval[0] != '\0')
02823     {
02824 #if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
02825       /* MacOS X 10.2 or newer.
02826          Ignore invalid LANG value set by the Terminal application.  */
02827       if (strcmp (retval, "UTF-8") != 0)
02828 #endif
02829 #if defined __CYGWIN__
02830       /* Cygwin.
02831          Ignore dummy LANG value set by ~/.profile.  */
02832       if (strcmp (retval, "C.UTF-8") != 0)
02833 #endif
02834         return retval;
02835     }
02836 
02837   return NULL;
02838 }
02839 
02840 const char *
02841 gl_locale_name_default (void)
02842 {
02843   /* POSIX:2001 says:
02844      "All implementations shall define a locale as the default locale, to be
02845       invoked when no environment variables are set, or set to the empty
02846       string.  This default locale can be the POSIX locale or any other
02847       implementation-defined locale.  Some implementations may provide
02848       facilities for local installation administrators to set the default
02849       locale, customizing it for each location.  POSIX:2001 does not require
02850       such a facility.
02851 
02852      The systems with such a facility are MacOS X and Windows: They provide a
02853      GUI that allows the user to choose a locale.
02854        - On MacOS X, by default, none of LC_* or LANG are set.  Starting with
02855          MacOS X 10.4 or 10.5, LANG is set for processes launched by the
02856          'Terminal' application (but sometimes to an incorrect value "UTF-8").
02857          When no environment variable is set, setlocale (LC_ALL, "") uses the
02858          "C" locale.
02859        - On native Windows, by default, none of LC_* or LANG are set.
02860          When no environment variable is set, setlocale (LC_ALL, "") uses the
02861          locale chosen by the user.
02862        - On Cygwin 1.5.x, by default, none of LC_* or LANG are set.
02863          When no environment variable is set, setlocale (LC_ALL, "") uses the
02864          "C" locale.
02865        - On Cygwin 1.7, by default, LANG is set to "C.UTF-8" when the default
02866          ~/.profile is executed.
02867          When no environment variable is set, setlocale (LC_ALL, "") uses the
02868          "C.UTF-8" locale, which operates in the same way as the "C" locale.
02869   */
02870 
02871 #if !(HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE || defined WIN32_NATIVE || defined __CYGWIN__)
02872 
02873   /* The system does not have a way of setting the locale, other than the
02874      POSIX specified environment variables.  We use C as default locale.  */
02875   return "C";
02876 
02877 #else
02878 
02879   /* Return an XPG style locale name language[_territory][@modifier].
02880      Don't even bother determining the codeset; it's not useful in this
02881      context, because message catalogs are not specific to a single
02882      codeset.  */
02883 
02884 # if HAVE_CFLOCALECOPYCURRENT || HAVE_CFPREFERENCESCOPYAPPVALUE
02885   /* MacOS X 10.2 or newer */
02886   {
02887     /* Cache the locale name, since CoreFoundation calls are expensive.  */
02888     static const char *cached_localename;
02889 
02890     if (cached_localename == NULL)
02891       {
02892         char namebuf[256];
02893 #  if HAVE_CFLOCALECOPYCURRENT /* MacOS X 10.3 or newer */
02894         CFLocaleRef locale = CFLocaleCopyCurrent ();
02895         CFStringRef name = CFLocaleGetIdentifier (locale);
02896 
02897         if (CFStringGetCString (name, namebuf, sizeof (namebuf),
02898                                 kCFStringEncodingASCII))
02899           {
02900             gl_locale_name_canonicalize (namebuf);
02901             cached_localename = strdup (namebuf);
02902           }
02903         CFRelease (locale);
02904 #  elif HAVE_CFPREFERENCESCOPYAPPVALUE /* MacOS X 10.2 or newer */
02905         CFTypeRef value =
02906           CFPreferencesCopyAppValue (CFSTR ("AppleLocale"),
02907                                      kCFPreferencesCurrentApplication);
02908         if (value != NULL
02909             && CFGetTypeID (value) == CFStringGetTypeID ()
02910             && CFStringGetCString ((CFStringRef)value,
02911                                    namebuf, sizeof (namebuf),
02912                                    kCFStringEncodingASCII))
02913           {
02914             gl_locale_name_canonicalize (namebuf);
02915             cached_localename = strdup (namebuf);
02916           }
02917 #  endif
02918         if (cached_localename == NULL)
02919           cached_localename = "C";
02920       }
02921     return cached_localename;
02922   }
02923 
02924 # endif
02925 
02926 # if defined WIN32_NATIVE || defined __CYGWIN__ /* WIN32 or Cygwin */
02927   {
02928     LCID lcid;
02929 
02930     /* Use native Win32 API locale ID.  */
02931     lcid = GetThreadLocale ();
02932 
02933     return gl_locale_name_from_win32_LCID (lcid);
02934   }
02935 # endif
02936 #endif
02937 }
02938 
02939 /* Determine the current locale's name, and canonicalize it into XPG syntax
02940      language[_territory][.codeset][@modifier]
02941    The codeset part in the result is not reliable; the locale_charset()
02942    should be used for codeset information instead.
02943    The result must not be freed; it is statically allocated.  */
02944 
02945 const char *
02946 gl_locale_name (int category, const char *categoryname)
02947 {
02948   const char *retval;
02949 
02950   retval = gl_locale_name_thread (category, categoryname);
02951   if (retval != NULL)
02952     return retval;
02953 
02954   retval = gl_locale_name_posix (category, categoryname);
02955   if (retval != NULL)
02956     return retval;
02957 
02958   return gl_locale_name_default ();
02959 }