]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/winutil.cpp
2 ********************************************************************************
3 * Copyright (C) 2005-2013, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ********************************************************************************
9 ********************************************************************************
12 #include "unicode/utypes.h"
14 #if U_PLATFORM_HAS_WIN32_API
16 #if !UCONFIG_NO_FORMATTING
20 #include "unicode/uloc.h"
22 # define WIN32_LEAN_AND_MEAN
32 static Win32Utilities::LCIDRecord
*lcidRecords
= NULL
;
33 static int32_t lcidCount
= 0;
34 static int32_t lcidMax
= 0;
36 BOOL CALLBACK
EnumLocalesProc(LPSTR lpLocaleString
)
38 char localeID
[ULOC_FULLNAME_CAPACITY
];
40 UErrorCode status
= U_ZERO_ERROR
;
42 if (lcidCount
>= lcidMax
) {
43 Win32Utilities::LCIDRecord
*newRecords
= new Win32Utilities::LCIDRecord
[lcidMax
+ 32];
45 for (int i
= 0; i
< lcidMax
; i
+= 1) {
46 newRecords
[i
] = lcidRecords
[i
];
50 lcidRecords
= newRecords
;
54 sscanf(lpLocaleString
, "%8x", &lcidRecords
[lcidCount
].lcid
);
56 localeIDLen
= uprv_convertToPosix(lcidRecords
[lcidCount
].lcid
, localeID
, sizeof(localeID
)/sizeof(localeID
[0]), &status
);
57 if (U_SUCCESS(status
)) {
58 lcidRecords
[lcidCount
].localeID
= new char[localeIDLen
+ 1];
59 memcpy(lcidRecords
[lcidCount
].localeID
, localeID
, localeIDLen
);
60 lcidRecords
[lcidCount
].localeID
[localeIDLen
] = 0;
62 lcidRecords
[lcidCount
].localeID
= NULL
;
70 Win32Utilities::LCIDRecord
*Win32Utilities::getLocales(int32_t &localeCount
)
74 EnumSystemLocalesA(EnumLocalesProc
, LCID_INSTALLED
);
76 localeCount
= lcidCount
;
79 lcidCount
= lcidMax
= 0;
85 void Win32Utilities::freeLocales(LCIDRecord
*records
)
87 for (int i
= 0; i
< lcidCount
; i
++) {
88 delete lcidRecords
[i
].localeID
;
93 #endif /* #if !UCONFIG_NO_FORMATTING */
95 #endif /* U_PLATFORM_HAS_WIN32_API */