5858// (U_ICU_VERSION_MAJOR_NUM < 52)
5959// The following APIs are not supported in the ICU versions less than 52. We need to define them manually.
6060// We have to do runtime check before using the pointers to these APIs. That is why these are listed in the FOR_ALL_OPTIONAL_ICU_FUNCTIONS list.
61+ U_CAPI void U_EXPORT2 ucol_setMaxVariable (UCollator * coll , UColReorderCode group , UErrorCode * pErrorCode );
6162U_CAPI int32_t U_EXPORT2 ucal_getTimeZoneIDForWindowsID (const UChar * winid , int32_t len , const char * region , UChar * id , int32_t idCapacity , UErrorCode * status );
6263U_CAPI int32_t U_EXPORT2 ucal_getWindowsTimeZoneID (const UChar * id , int32_t len , UChar * winid , int32_t winidCapacity , UErrorCode * status );
63- #endif
64+
65+ // (U_ICU_VERSION_MAJOR_NUM < 71)
66+ // The following API is not supported in the ICU versions less than 71. We need to define it manually.
67+ // We have to do runtime check before using the pointers to this API. That is why these are listed in the FOR_ALL_OPTIONAL_ICU_FUNCTIONS list.
68+ U_CAPI UCollator * U_EXPORT2 ucol_clone (const UCollator * coll , UErrorCode * status );
69+
70+ // ucol_setVariableTop is a deprecated function on the newer ICU versions and ucol_setMaxVariable should be used instead.
71+ // As can run against ICU versions which not supported ucol_setMaxVariable, we'll dynamically try to get the pointer to ucol_setVariableTop
72+ // when we couldn't get a pointer to ucol_setMaxVariable.
73+ typedef uint32_t (U_EXPORT2 * ucol_setVariableTop_func )(UCollator * coll , const UChar * varTop , int32_t len , UErrorCode * status );
74+
75+ // ucol_safeClone is deprecated in ICU version 71. We have to handle it manually to avoid getting a build break when referencing it in the code.
76+ typedef UCollator * (U_EXPORT2 * ucol_safeClone_func )(const UCollator * coll , void * stackBuffer , int32_t * pBufferSize , UErrorCode * status );
77+
78+ #else // !defined(TARGET_ANDROID)
79+
80+ typedef uint32_t (* ucol_setVariableTop_func )(UCollator * coll , const UChar * varTop , int32_t len , UErrorCode * status );
81+ typedef UCollator * (* ucol_safeClone_func )(const UCollator * coll , void * stackBuffer , int32_t * pBufferSize , UErrorCode * status );
82+
83+ #endif // !defined(TARGET_ANDROID)
84+
85+ extern ucol_setVariableTop_func ucol_setVariableTop_ptr ;
86+ extern ucol_safeClone_func ucol_safeClone_ptr ;
6487
6588// List of all functions from the ICU libraries that are used in the System.Globalization.Native.so
6689#define FOR_ALL_UNCONDITIONAL_ICU_FUNCTIONS \
@@ -99,7 +122,6 @@ U_CAPI int32_t U_EXPORT2 ucal_getWindowsTimeZoneID(const UChar* id, int32_t len,
99122 PER_FUNCTION_BLOCK(ucol_open, libicui18n, true) \
100123 PER_FUNCTION_BLOCK(ucol_openElements, libicui18n, true) \
101124 PER_FUNCTION_BLOCK(ucol_openRules, libicui18n, true) \
102- PER_FUNCTION_BLOCK(ucol_safeClone, libicui18n, true) \
103125 PER_FUNCTION_BLOCK(ucol_setAttribute, libicui18n, true) \
104126 PER_FUNCTION_BLOCK(ucol_strcoll, libicui18n, true) \
105127 PER_FUNCTION_BLOCK(udat_close, libicui18n, true) \
@@ -164,15 +186,6 @@ U_CAPI int32_t U_EXPORT2 ucal_getWindowsTimeZoneID(const UChar* id, int32_t len,
164186 PER_FUNCTION_BLOCK(usearch_setPattern, libicui18n, true) \
165187 PER_FUNCTION_BLOCK(usearch_setText, libicui18n, true)
166188
167- #if HAVE_SET_MAX_VARIABLE
168- #define FOR_ALL_SET_VARIABLE_ICU_FUNCTIONS \
169- PER_FUNCTION_BLOCK(ucol_setMaxVariable, libicui18n, true)
170- #else
171-
172- #define FOR_ALL_SET_VARIABLE_ICU_FUNCTIONS \
173- PER_FUNCTION_BLOCK(ucol_setVariableTop, libicui18n, true)
174- #endif
175-
176189#if defined(TARGET_WINDOWS )
177190#define FOR_ALL_OS_CONDITIONAL_ICU_FUNCTIONS \
178191 PER_FUNCTION_BLOCK(ucurr_forLocale, libicuuc, true) \
@@ -195,11 +208,12 @@ U_CAPI int32_t U_EXPORT2 ucal_getWindowsTimeZoneID(const UChar* id, int32_t len,
195208// Otherwise, we'll just not provide the functionality to users which needed these APIs.
196209#define FOR_ALL_OPTIONAL_ICU_FUNCTIONS \
197210 PER_FUNCTION_BLOCK(ucal_getWindowsTimeZoneID, libicui18n, false) \
198- PER_FUNCTION_BLOCK(ucal_getTimeZoneIDForWindowsID, libicui18n, false)
211+ PER_FUNCTION_BLOCK(ucal_getTimeZoneIDForWindowsID, libicui18n, false) \
212+ PER_FUNCTION_BLOCK(ucol_setMaxVariable, libicui18n, false) \
213+ PER_FUNCTION_BLOCK(ucol_clone, libicui18n, false)
199214
200215#define FOR_ALL_ICU_FUNCTIONS \
201216 FOR_ALL_UNCONDITIONAL_ICU_FUNCTIONS \
202- FOR_ALL_SET_VARIABLE_ICU_FUNCTIONS \
203217 FOR_ALL_OPTIONAL_ICU_FUNCTIONS \
204218 FOR_ALL_OS_CONDITIONAL_ICU_FUNCTIONS
205219
@@ -235,6 +249,7 @@ FOR_ALL_ICU_FUNCTIONS
235249#define ucal_openTimeZoneIDEnumeration (...) ucal_openTimeZoneIDEnumeration_ptr(__VA_ARGS__)
236250#define ucal_set (...) ucal_set_ptr(__VA_ARGS__)
237251#define ucal_setMillis (...) ucal_setMillis_ptr(__VA_ARGS__)
252+ #define ucol_clone (...) ucol_clone_ptr(__VA_ARGS__)
238253#define ucol_close (...) ucol_close_ptr(__VA_ARGS__)
239254#define ucol_closeElements (...) ucol_closeElements_ptr(__VA_ARGS__)
240255#define ucol_getOffset (...) ucol_getOffset_ptr(__VA_ARGS__)
@@ -247,13 +262,8 @@ FOR_ALL_ICU_FUNCTIONS
247262#define ucol_open (...) ucol_open_ptr(__VA_ARGS__)
248263#define ucol_openElements (...) ucol_openElements_ptr(__VA_ARGS__)
249264#define ucol_openRules (...) ucol_openRules_ptr(__VA_ARGS__)
250- #define ucol_safeClone (...) ucol_safeClone_ptr(__VA_ARGS__)
251265#define ucol_setAttribute (...) ucol_setAttribute_ptr(__VA_ARGS__)
252- #if HAVE_SET_MAX_VARIABLE
253266#define ucol_setMaxVariable (...) ucol_setMaxVariable_ptr(__VA_ARGS__)
254- #else
255- #define ucol_setVariableTop (...) ucol_setVariableTop_ptr(__VA_ARGS__)
256- #endif
257267#define ucol_strcoll (...) ucol_strcoll_ptr(__VA_ARGS__)
258268#define ucurr_forLocale (...) ucurr_forLocale_ptr(__VA_ARGS__)
259269#define ucurr_getName (...) ucurr_getName_ptr(__VA_ARGS__)
0 commit comments