]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/winutil.cpp
2 ********************************************************************************
3 * Copyright (C) 2005-2016, 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
21 #include "unicode/uloc.h"
23 # define WIN32_LEAN_AND_MEAN
33 static Win32Utilities::LCIDRecord
*lcidRecords
= NULL
;
34 static int32_t lcidCount
= 0;
35 static int32_t lcidMax
= 0;
37 BOOL CALLBACK
EnumLocalesProc(LPSTR lpLocaleString
)
39 char localeID
[ULOC_FULLNAME_CAPACITY
];
41 UErrorCode status
= U_ZERO_ERROR
;
43 if (lcidCount
>= lcidMax
) {
44 Win32Utilities::LCIDRecord
*newRecords
= new Win32Utilities::LCIDRecord
[lcidMax
+ 32];
46 for (int i
= 0; i
< lcidMax
; i
+= 1) {
47 newRecords
[i
] = lcidRecords
[i
];
51 lcidRecords
= newRecords
;
55 sscanf(lpLocaleString
, "%8x", &lcidRecords
[lcidCount
].lcid
);
57 localeIDLen
= uprv_convertToPosix(lcidRecords
[lcidCount
].lcid
, localeID
, UPRV_LENGTHOF(localeID
), &status
);
58 if (U_SUCCESS(status
)) {
59 lcidRecords
[lcidCount
].localeID
= new char[localeIDLen
+ 1];
60 memcpy(lcidRecords
[lcidCount
].localeID
, localeID
, localeIDLen
);
61 lcidRecords
[lcidCount
].localeID
[localeIDLen
] = 0;
63 lcidRecords
[lcidCount
].localeID
= NULL
;
71 Win32Utilities::LCIDRecord
*Win32Utilities::getLocales(int32_t &localeCount
)
75 EnumSystemLocalesA(EnumLocalesProc
, LCID_INSTALLED
);
77 localeCount
= lcidCount
;
80 lcidCount
= lcidMax
= 0;
86 void Win32Utilities::freeLocales(LCIDRecord
*records
)
88 for (int i
= 0; i
< lcidCount
; i
++) {
89 delete lcidRecords
[i
].localeID
;
94 #endif /* #if !UCONFIG_NO_FORMATTING */
96 #endif /* U_PLATFORM_HAS_WIN32_API */