]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/winutil.cpp
2 ********************************************************************************
3 * Copyright (C) 2005-2011, 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 const char* localeID
= NULL
;
39 UErrorCode status
= U_ZERO_ERROR
;
41 if (lcidCount
>= lcidMax
) {
42 Win32Utilities::LCIDRecord
*newRecords
= new Win32Utilities::LCIDRecord
[lcidMax
+ 32];
44 for (int i
= 0; i
< lcidMax
; i
+= 1) {
45 newRecords
[i
] = lcidRecords
[i
];
49 lcidRecords
= newRecords
;
53 sscanf(lpLocaleString
, "%8x", &lcidRecords
[lcidCount
].lcid
);
55 localeID
= uprv_convertToPosix(lcidRecords
[lcidCount
].lcid
, &status
);
57 lcidRecords
[lcidCount
].localeID
= new char[strlen(localeID
)];
59 strcpy(lcidRecords
[lcidCount
].localeID
, localeID
);
66 Win32Utilities::LCIDRecord
*Win32Utilities::getLocales(int32_t &localeCount
)
70 EnumSystemLocalesA(EnumLocalesProc
, LCID_INSTALLED
);
72 localeCount
= lcidCount
;
75 lcidCount
= lcidMax
= 0;
81 void Win32Utilities::freeLocales(LCIDRecord
*records
)
83 for (int i
= 0; i
< lcidCount
; i
++) {
84 delete lcidRecords
[i
].localeID
;
89 #endif /* #if !UCONFIG_NO_FORMATTING */
91 #endif /* U_PLATFORM_HAS_WIN32_API */