]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/winutil.cpp
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 ********************************************************************************
5 * Copyright (C) 2005-2016, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 ********************************************************************************
11 ********************************************************************************
14 #include "unicode/utypes.h"
16 #if U_PLATFORM_HAS_WIN32_API
18 #if !UCONFIG_NO_FORMATTING
23 #include "unicode/uloc.h"
25 # define WIN32_LEAN_AND_MEAN
35 static Win32Utilities::LCIDRecord
*lcidRecords
= NULL
;
36 static int32_t lcidCount
= 0;
37 static int32_t lcidMax
= 0;
39 // TODO: Note that this test will skip locale names and only hit locales with assigned LCIDs
40 BOOL CALLBACK
EnumLocalesProc(LPSTR lpLocaleString
)
42 char localeID
[ULOC_FULLNAME_CAPACITY
];
44 UErrorCode status
= U_ZERO_ERROR
;
46 if (lcidCount
>= lcidMax
) {
47 Win32Utilities::LCIDRecord
*newRecords
= new Win32Utilities::LCIDRecord
[lcidMax
+ 32];
49 for (int i
= 0; i
< lcidMax
; i
+= 1) {
50 newRecords
[i
] = lcidRecords
[i
];
54 lcidRecords
= newRecords
;
58 sscanf(lpLocaleString
, "%8x", &lcidRecords
[lcidCount
].lcid
);
60 localeIDLen
= uprv_convertToPosix(lcidRecords
[lcidCount
].lcid
, localeID
, UPRV_LENGTHOF(localeID
), &status
);
61 if (U_SUCCESS(status
)) {
62 lcidRecords
[lcidCount
].localeID
= new char[localeIDLen
+ 1];
63 memcpy(lcidRecords
[lcidCount
].localeID
, localeID
, localeIDLen
);
64 lcidRecords
[lcidCount
].localeID
[localeIDLen
] = 0;
66 lcidRecords
[lcidCount
].localeID
= NULL
;
74 // TODO: Note that this test will skip locale names and only hit locales with assigned LCIDs
75 Win32Utilities::LCIDRecord
*Win32Utilities::getLocales(int32_t &localeCount
)
79 EnumSystemLocalesA(EnumLocalesProc
, LCID_INSTALLED
);
81 localeCount
= lcidCount
;
84 lcidCount
= lcidMax
= 0;
90 void Win32Utilities::freeLocales(LCIDRecord
*records
)
92 for (int i
= 0; i
< lcidCount
; i
++) {
93 delete lcidRecords
[i
].localeID
;
98 #endif /* #if !UCONFIG_NO_FORMATTING */
100 #endif /* U_PLATFORM_HAS_WIN32_API */