}
-extern "C" int32_t GlobalizationNative_GetSortVersion()
-{
- // we didn't use UCOL_TAILORINGS_VERSION because it is deprecated in ICU v5
- return UCOL_RUNTIME_VERSION << 16 | UCOL_BUILDER_VERSION;
-}
-
extern "C" ResultCode GlobalizationNative_GetSortHandle(const char* lpLocaleName, SortHandle** ppSortHandle)
{
assert(ppSortHandle != nullptr);
return pCollator;
}
+extern "C" int32_t GlobalizationNative_GetSortVersion(SortHandle* pSortHandle)
+{
+ UErrorCode err = U_ZERO_ERROR;
+ const UCollator* pColl = GetCollatorFromSortHandle(pSortHandle, 0, &err);
+ int32_t result = 0;
+
+ if (U_SUCCESS(err))
+ {
+ ucol_getVersion(pColl, (uint8_t *) &result);
+ }
+ else
+ {
+ assert(false && "Unexpected ucol_getVersion to fail.");
+
+ // we didn't use UCOL_TAILORINGS_VERSION because it is deprecated in ICU v5
+ result = UCOL_RUNTIME_VERSION << 16 | UCOL_BUILDER_VERSION;
+ }
+ return result;
+}
+
/*
Function:
CompareString
// List of all functions from the ICU libraries that are used in the System.Globalization.Native.so
#define FOR_ALL_UNCONDITIONAL_ICU_FUNCTIONS \
PER_FUNCTION_BLOCK(u_charsToUChars, libicuuc) \
+ PER_FUNCTION_BLOCK(u_getVersion, libicuuc) \
PER_FUNCTION_BLOCK(u_strlen, libicuuc) \
PER_FUNCTION_BLOCK(u_strncpy, libicuuc) \
PER_FUNCTION_BLOCK(u_tolower, libicuuc) \
PER_FUNCTION_BLOCK(ucol_getRules, libicui18n) \
PER_FUNCTION_BLOCK(ucol_getSortKey, libicui18n) \
PER_FUNCTION_BLOCK(ucol_getStrength, libicui18n) \
+ PER_FUNCTION_BLOCK(ucol_getVersion, libicui18n) \
PER_FUNCTION_BLOCK(ucol_next, libicui18n) \
PER_FUNCTION_BLOCK(ucol_open, libicui18n) \
PER_FUNCTION_BLOCK(ucol_openElements, libicui18n) \
// Redefine all calls to ICU functions as calls through pointers that are set
// to the functions of the selected version of ICU in the initialization.
#define u_charsToUChars(...) u_charsToUChars_ptr(__VA_ARGS__)
+#define u_getVersion(...) u_getVersion_ptr(__VA_ARGS__)
#define u_strlen(...) u_strlen_ptr(__VA_ARGS__)
#define u_strncpy(...) u_strncpy_ptr(__VA_ARGS__)
#define u_tolower(...) u_tolower_ptr(__VA_ARGS__)
#define ucol_getRules(...) ucol_getRules_ptr(__VA_ARGS__)
#define ucol_getSortKey(...) ucol_getSortKey_ptr(__VA_ARGS__)
#define ucol_getStrength(...) ucol_getStrength_ptr(__VA_ARGS__)
+#define ucol_getVersion(...) ucol_getVersion_ptr(__VA_ARGS__)
#define ucol_next(...) ucol_next_ptr(__VA_ARGS__)
#define ucol_open(...) ucol_open_ptr(__VA_ARGS__)
#define ucol_openElements(...) ucol_openElements_ptr(__VA_ARGS__)
{
Debug.Assert(!_invariantMode);
- int sortVersion = Interop.GlobalizationInterop.GetSortVersion();
+ int sortVersion = Interop.GlobalizationInterop.GetSortVersion(_sortHandle);
return new SortVersion(sortVersion, LCID, new Guid(sortVersion, 0, 0, 0, 0, 0, 0,
(byte) (LCID >> 24),
(byte) ((LCID & 0x00FF0000) >> 16),