OLD | NEW |
1 /* | 1 /* |
2 ********************************************************************** | 2 ********************************************************************** |
3 * Copyright (C) 1996-2013, International Business Machines | 3 * Copyright (C) 1996-2014, International Business Machines |
4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
5 ********************************************************************** | 5 ********************************************************************** |
6 * | 6 * |
7 * Provides functionality for mapping between | 7 * Provides functionality for mapping between |
8 * LCID and Posix IDs or ICU locale to codepage | 8 * LCID and Posix IDs or ICU locale to codepage |
9 * | 9 * |
10 * Note: All classes and code in this file are | 10 * Note: All classes and code in this file are |
11 * intended for internal use only. | 11 * intended for internal use only. |
12 * | 12 * |
13 * Methods of interest: | 13 * Methods of interest: |
14 * unsigned long convertToLCID(const char*); | 14 * unsigned long convertToLCID(const char*); |
15 * const char* convertToPosix(unsigned long); | 15 * const char* convertToPosix(unsigned long); |
16 * | 16 * |
17 * Kathleen Wilson, 4/30/96 | 17 * Kathleen Wilson, 4/30/96 |
18 * | 18 * |
19 * Date Name Description | 19 * Date Name Description |
20 * 3/11/97 aliu Fixed off-by-one bug in assignment operator. Added | 20 * 3/11/97 aliu Fixed off-by-one bug in assignment operator. Added |
21 * setId() method and safety check against | 21 * setId() method and safety check against |
22 * MAX_ID_LENGTH. | 22 * MAX_ID_LENGTH. |
23 * 04/23/99 stephen Added C wrapper for convertToPosix. | 23 * 04/23/99 stephen Added C wrapper for convertToPosix. |
24 * 09/18/00 george Removed the memory leaks. | 24 * 09/18/00 george Removed the memory leaks. |
25 * 08/23/01 george Convert to C | 25 * 08/23/01 george Convert to C |
26 */ | 26 */ |
27 | 27 |
28 #include "locmap.h" | 28 #include "locmap.h" |
29 #include "cstring.h" | 29 #include "cstring.h" |
30 #include "cmemory.h" | 30 #include "cmemory.h" |
31 | 31 |
32 #if 0 | |
33 #if U_PLATFORM == U_PF_WINDOWS && defined(_MSC_VER) && (_MSC_VER >= 1500) | 32 #if U_PLATFORM == U_PF_WINDOWS && defined(_MSC_VER) && (_MSC_VER >= 1500) |
34 /* | 33 /* |
35 * TODO: It seems like we should widen this to | 34 * TODO: It seems like we should widen this to |
36 * either U_PLATFORM_USES_ONLY_WIN32_API (includes MinGW) | 35 * either U_PLATFORM_USES_ONLY_WIN32_API (includes MinGW) |
37 * or U_PLATFORM_HAS_WIN32_API (includes MinGW and Cygwin) | 36 * or U_PLATFORM_HAS_WIN32_API (includes MinGW and Cygwin) |
38 * but those use gcc and won't have defined(_MSC_VER). | 37 * but those use gcc and won't have defined(_MSC_VER). |
39 * We might need to #include some Windows header and test for some version macro
from there. | 38 * We might need to #include some Windows header and test for some version macro
from there. |
40 * Or call some Windows function and see what it returns. | 39 * Or call some Windows function and see what it returns. |
41 */ | 40 */ |
42 #define USE_WINDOWS_LOCALE_API | 41 #define USE_WINDOWS_LOCALE_API |
43 #endif | 42 #endif |
44 #endif | |
45 | 43 |
46 #ifdef USE_WINDOWS_LOCALE_API | 44 #ifdef USE_WINDOWS_LOCALE_API |
47 #include <windows.h> | 45 #include <windows.h> |
48 #include <winnls.h> | 46 #include <winnls.h> |
49 #endif | 47 #endif |
50 | 48 |
51 /* | 49 /* |
52 * Note: | 50 * Note: |
53 * The mapping from Win32 locale ID numbers to POSIX locale strings should | 51 * The mapping from Win32 locale ID numbers to POSIX locale strings should |
54 * be the faster one. | 52 * be the faster one. |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 {0x081a, "sr_Latn_CS"}, /* Serbo-Croatian*/ | 393 {0x081a, "sr_Latn_CS"}, /* Serbo-Croatian*/ |
396 {0x701a, "sr_Latn"}, /* It's 0x1a or 0x081a, pick one to make the test pr
ogram happy. */ | 394 {0x701a, "sr_Latn"}, /* It's 0x1a or 0x081a, pick one to make the test pr
ogram happy. */ |
397 {0x1c1a, "sr_Cyrl_BA"}, /* Serbo-Croatian in Bosnia */ | 395 {0x1c1a, "sr_Cyrl_BA"}, /* Serbo-Croatian in Bosnia */ |
398 {0x0c1a, "sr_Cyrl_CS"}, /* Serbian*/ | 396 {0x0c1a, "sr_Cyrl_CS"}, /* Serbian*/ |
399 {0x301a, "sr_Cyrl_ME"}, | 397 {0x301a, "sr_Cyrl_ME"}, |
400 {0x281a, "sr_Cyrl_RS"}, | 398 {0x281a, "sr_Cyrl_RS"}, |
401 {0x6c1a, "sr_Cyrl"}, /* It's 0x1a or 0x0c1a, pick one to make the test pr
ogram happy. */ | 399 {0x6c1a, "sr_Cyrl"}, /* It's 0x1a or 0x0c1a, pick one to make the test pr
ogram happy. */ |
402 {0x7c1a, "sr"} /* In CLDR sr is sr_Cyrl. */ | 400 {0x7c1a, "sr"} /* In CLDR sr is sr_Cyrl. */ |
403 }; | 401 }; |
404 | 402 |
| 403 ILCID_POSIX_SUBTABLE(hsb) { |
| 404 {0x2E, "hsb"}, |
| 405 {0x042E, "hsb_DE"}, |
| 406 {0x082E, "dsb_DE"}, |
| 407 {0x7C2E, "dsb"}, |
| 408 }; |
| 409 |
405 ILCID_POSIX_ELEMENT_ARRAY(0x040e, hu, hu_HU) | 410 ILCID_POSIX_ELEMENT_ARRAY(0x040e, hu, hu_HU) |
406 ILCID_POSIX_ELEMENT_ARRAY(0x042b, hy, hy_AM) | 411 ILCID_POSIX_ELEMENT_ARRAY(0x042b, hy, hy_AM) |
407 ILCID_POSIX_ELEMENT_ARRAY(0x0469, ibb, ibb_NG) | 412 ILCID_POSIX_ELEMENT_ARRAY(0x0469, ibb, ibb_NG) |
408 ILCID_POSIX_ELEMENT_ARRAY(0x0421, id, id_ID) | 413 ILCID_POSIX_ELEMENT_ARRAY(0x0421, id, id_ID) |
409 ILCID_POSIX_ELEMENT_ARRAY(0x0470, ig, ig_NG) | 414 ILCID_POSIX_ELEMENT_ARRAY(0x0470, ig, ig_NG) |
410 ILCID_POSIX_ELEMENT_ARRAY(0x0478, ii, ii_CN) | 415 ILCID_POSIX_ELEMENT_ARRAY(0x0478, ii, ii_CN) |
411 ILCID_POSIX_ELEMENT_ARRAY(0x040f, is, is_IS) | 416 ILCID_POSIX_ELEMENT_ARRAY(0x040f, is, is_IS) |
412 | 417 |
413 ILCID_POSIX_SUBTABLE(it) { | 418 ILCID_POSIX_SUBTABLE(it) { |
414 {0x10, "it"}, | 419 {0x10, "it"}, |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 {0x7c43, "uz_Latn"} /* Latin based */ | 686 {0x7c43, "uz_Latn"} /* Latin based */ |
682 }; | 687 }; |
683 | 688 |
684 ILCID_POSIX_SUBTABLE(ve) { /* TODO: Verify the country */ | 689 ILCID_POSIX_SUBTABLE(ve) { /* TODO: Verify the country */ |
685 {0x33, "ve"}, | 690 {0x33, "ve"}, |
686 {0x0433, "ve_ZA"}, | 691 {0x0433, "ve_ZA"}, |
687 {0x0433, "ven_ZA"} | 692 {0x0433, "ven_ZA"} |
688 }; | 693 }; |
689 | 694 |
690 ILCID_POSIX_ELEMENT_ARRAY(0x042a, vi, vi_VN) | 695 ILCID_POSIX_ELEMENT_ARRAY(0x042a, vi, vi_VN) |
691 | |
692 ILCID_POSIX_SUBTABLE(wen) { | |
693 {0x2E, "wen"}, | |
694 {0x042E, "wen_DE"}, | |
695 {0x042E, "hsb_DE"}, | |
696 {0x082E, "dsb_DE"}, | |
697 {0x7C2E, "dsb"}, | |
698 {0x2E, "hsb"} | |
699 }; | |
700 | |
701 ILCID_POSIX_ELEMENT_ARRAY(0x0488, wo, wo_SN) | 696 ILCID_POSIX_ELEMENT_ARRAY(0x0488, wo, wo_SN) |
702 ILCID_POSIX_ELEMENT_ARRAY(0x0434, xh, xh_ZA) | 697 ILCID_POSIX_ELEMENT_ARRAY(0x0434, xh, xh_ZA) |
703 ILCID_POSIX_ELEMENT_ARRAY(0x043d, yi, yi) | 698 ILCID_POSIX_ELEMENT_ARRAY(0x043d, yi, yi) |
704 ILCID_POSIX_ELEMENT_ARRAY(0x046a, yo, yo_NG) | 699 ILCID_POSIX_ELEMENT_ARRAY(0x046a, yo, yo_NG) |
705 | 700 |
706 ILCID_POSIX_SUBTABLE(zh) { | 701 ILCID_POSIX_SUBTABLE(zh) { |
707 {0x0004, "zh_Hans"}, | 702 {0x0004, "zh_Hans"}, |
708 {0x7804, "zh"}, | 703 {0x7804, "zh"}, |
709 {0x0804, "zh_CN"}, | 704 {0x0804, "zh_CN"}, |
710 {0x0804, "zh_Hans_CN"}, | 705 {0x0804, "zh_Hans_CN"}, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 ILCID_POSIX_MAP(gd), /* gd Gaelic (United Kingdom) 0x91 */ | 769 ILCID_POSIX_MAP(gd), /* gd Gaelic (United Kingdom) 0x91 */ |
775 ILCID_POSIX_MAP(gl), /* gl Galician 0x56 */ | 770 ILCID_POSIX_MAP(gl), /* gl Galician 0x56 */ |
776 ILCID_POSIX_MAP(gn), /* gn Guarani 0x74 */ | 771 ILCID_POSIX_MAP(gn), /* gn Guarani 0x74 */ |
777 ILCID_POSIX_MAP(gsw), /* gsw Alemanic/Alsatian/Swiss German 0x84 */ | 772 ILCID_POSIX_MAP(gsw), /* gsw Alemanic/Alsatian/Swiss German 0x84 */ |
778 ILCID_POSIX_MAP(gu), /* gu Gujarati 0x47 */ | 773 ILCID_POSIX_MAP(gu), /* gu Gujarati 0x47 */ |
779 ILCID_POSIX_MAP(ha), /* ha Hausa 0x68 */ | 774 ILCID_POSIX_MAP(ha), /* ha Hausa 0x68 */ |
780 ILCID_POSIX_MAP(haw), /* haw Hawaiian 0x75 */ | 775 ILCID_POSIX_MAP(haw), /* haw Hawaiian 0x75 */ |
781 ILCID_POSIX_MAP(he), /* he Hebrew (formerly iw) 0x0d */ | 776 ILCID_POSIX_MAP(he), /* he Hebrew (formerly iw) 0x0d */ |
782 ILCID_POSIX_MAP(hi), /* hi Hindi 0x39 */ | 777 ILCID_POSIX_MAP(hi), /* hi Hindi 0x39 */ |
783 ILCID_POSIX_MAP(hr), /* * Croatian and others 0x1a */ | 778 ILCID_POSIX_MAP(hr), /* * Croatian and others 0x1a */ |
| 779 ILCID_POSIX_MAP(hsb), /* hsb Upper Sorbian 0x2e */ |
784 ILCID_POSIX_MAP(hu), /* hu Hungarian 0x0e */ | 780 ILCID_POSIX_MAP(hu), /* hu Hungarian 0x0e */ |
785 ILCID_POSIX_MAP(hy), /* hy Armenian 0x2b */ | 781 ILCID_POSIX_MAP(hy), /* hy Armenian 0x2b */ |
786 ILCID_POSIX_MAP(ibb), /* ibb Ibibio - Nigeria 0x69 */ | 782 ILCID_POSIX_MAP(ibb), /* ibb Ibibio - Nigeria 0x69 */ |
787 ILCID_POSIX_MAP(id), /* id Indonesian (formerly in) 0x21 */ | 783 ILCID_POSIX_MAP(id), /* id Indonesian (formerly in) 0x21 */ |
788 ILCID_POSIX_MAP(ig), /* ig Igbo 0x70 */ | 784 ILCID_POSIX_MAP(ig), /* ig Igbo 0x70 */ |
789 ILCID_POSIX_MAP(ii), /* ii Sichuan Yi 0x78 */ | 785 ILCID_POSIX_MAP(ii), /* ii Sichuan Yi 0x78 */ |
790 ILCID_POSIX_MAP(is), /* is Icelandic 0x0f */ | 786 ILCID_POSIX_MAP(is), /* is Icelandic 0x0f */ |
791 ILCID_POSIX_MAP(it), /* it Italian 0x10 */ | 787 ILCID_POSIX_MAP(it), /* it Italian 0x10 */ |
792 ILCID_POSIX_MAP(iu), /* iu Inuktitut 0x5d */ | 788 ILCID_POSIX_MAP(iu), /* iu Inuktitut 0x5d */ |
793 ILCID_POSIX_MAP(iw), /* iw Hebrew 0x0d */ | 789 ILCID_POSIX_MAP(iw), /* iw Hebrew 0x0d */ |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 ILCID_POSIX_MAP(tr), /* tr Turkish 0x1f */ | 859 ILCID_POSIX_MAP(tr), /* tr Turkish 0x1f */ |
864 ILCID_POSIX_MAP(ts), /* ts Tsonga 0x31 */ | 860 ILCID_POSIX_MAP(ts), /* ts Tsonga 0x31 */ |
865 ILCID_POSIX_MAP(tt), /* tt Tatar 0x44 */ | 861 ILCID_POSIX_MAP(tt), /* tt Tatar 0x44 */ |
866 ILCID_POSIX_MAP(tzm), /* tzm Tamazight 0x5f */ | 862 ILCID_POSIX_MAP(tzm), /* tzm Tamazight 0x5f */ |
867 ILCID_POSIX_MAP(ug), /* ug Uighur 0x80 */ | 863 ILCID_POSIX_MAP(ug), /* ug Uighur 0x80 */ |
868 ILCID_POSIX_MAP(uk), /* uk Ukrainian 0x22 */ | 864 ILCID_POSIX_MAP(uk), /* uk Ukrainian 0x22 */ |
869 ILCID_POSIX_MAP(ur), /* ur Urdu 0x20 */ | 865 ILCID_POSIX_MAP(ur), /* ur Urdu 0x20 */ |
870 ILCID_POSIX_MAP(uz), /* uz Uzbek 0x43 */ | 866 ILCID_POSIX_MAP(uz), /* uz Uzbek 0x43 */ |
871 ILCID_POSIX_MAP(ve), /* ve Venda 0x33 */ | 867 ILCID_POSIX_MAP(ve), /* ve Venda 0x33 */ |
872 ILCID_POSIX_MAP(vi), /* vi Vietnamese 0x2a */ | 868 ILCID_POSIX_MAP(vi), /* vi Vietnamese 0x2a */ |
873 ILCID_POSIX_MAP(wen), /* wen Sorbian 0x2e */ | |
874 ILCID_POSIX_MAP(wo), /* wo Wolof 0x88 */ | 869 ILCID_POSIX_MAP(wo), /* wo Wolof 0x88 */ |
875 ILCID_POSIX_MAP(xh), /* xh Xhosa 0x34 */ | 870 ILCID_POSIX_MAP(xh), /* xh Xhosa 0x34 */ |
876 ILCID_POSIX_MAP(yi), /* yi Yiddish 0x3d */ | 871 ILCID_POSIX_MAP(yi), /* yi Yiddish 0x3d */ |
877 ILCID_POSIX_MAP(yo), /* yo Yoruba 0x6a */ | 872 ILCID_POSIX_MAP(yo), /* yo Yoruba 0x6a */ |
878 ILCID_POSIX_MAP(zh), /* zh Chinese 0x04 */ | 873 ILCID_POSIX_MAP(zh), /* zh Chinese 0x04 */ |
879 ILCID_POSIX_MAP(zu), /* zu Zulu 0x35 */ | 874 ILCID_POSIX_MAP(zu), /* zu Zulu 0x35 */ |
880 }; | 875 }; |
881 | 876 |
882 static const uint32_t gLocaleCount = sizeof(gPosixIDmap)/sizeof(ILcidPosixMap); | 877 static const uint32_t gLocaleCount = sizeof(gPosixIDmap)/sizeof(ILcidPosixMap); |
883 | 878 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 if (fallbackValue != (uint32_t)-1) { | 1126 if (fallbackValue != (uint32_t)-1) { |
1132 *status = U_USING_FALLBACK_WARNING; | 1127 *status = U_USING_FALLBACK_WARNING; |
1133 return fallbackValue; | 1128 return fallbackValue; |
1134 } | 1129 } |
1135 | 1130 |
1136 /* no match found */ | 1131 /* no match found */ |
1137 *status = U_ILLEGAL_ARGUMENT_ERROR; | 1132 *status = U_ILLEGAL_ARGUMENT_ERROR; |
1138 return 0; /* return international (root) */ | 1133 return 0; /* return international (root) */ |
1139 } | 1134 } |
1140 | 1135 |
OLD | NEW |