Skip to content

Commit

Permalink
Fea, CompareString(W/A) 新增NORM_LINGUISTIC_CASING标记支持
Browse files Browse the repository at this point in the history
  • Loading branch information
mingkuang-Chuyu committed Sep 4, 2024
1 parent cb0baea commit 5652ff5
Showing 1 changed file with 31 additions and 21 deletions.
52 changes: 31 additions & 21 deletions src/Thunks/api-ms-win-core-string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,25 +265,11 @@ namespace YY::Thunks
#endif


#if defined(YY_Thunks_Implemented) && (YY_Thunks_Target < __WindowsNT5_1)
static bool IsSupportLOCALE_INVARIANT()
{
// 特意不考虑多线程支持,因为这里产生写入竞争并没有关系。
static int s_iStat = 0;
if (s_iStat == 0)
{
s_iStat = internal::GetSystemVersion() >= internal::MakeVersion(5, 1) ? 1 : -1;
}
return s_iStat == 1;
}
#endif


#if (YY_Thunks_Target < __WindowsNT5_1)
#if (YY_Thunks_Target < __WindowsNT6)

// Windows 2000 不支持 LOCALE_INVARIANT 参数特殊处理一下。
// Minimum supported client Windows 2000 Professional [desktop apps only]
// Minimum supported server Windows 2000 Server [desktop apps only]
// 虽然Windows 2000已经支持,但是几个新标记老系统不支持,特殊处理一下。
__DEFINE_THUNK(
kernel32,
24,
Expand All @@ -305,21 +291,33 @@ namespace YY::Thunks
return 0;
}

if (Locale == LOCALE_INVARIANT && IsSupportLOCALE_INVARIANT() == false)
#if (YY_Thunks_Target < __WindowsNT5_1)
// Windows 2000 不支持 LOCALE_INVARIANT 参数特殊处理一下。
// 网友 海好蓝 提供
if (Locale == LOCALE_INVARIANT && internal::GetSystemVersion() < internal::MakeVersion(5, 1))
{
Locale = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
}
#endif

#if (YY_Thunks_Target < __WindowsNT6)
// Windows XP不支持 NORM_LINGUISTIC_CASING
// 网友 海好蓝 反馈
if (internal::GetSystemVersion() < internal::MakeVersion(6, 0))
{
dwCmpFlags &= ~NORM_LINGUISTIC_CASING;
}
#endif
return _pfnCompareStringA(Locale, dwCmpFlags, lpString1, cchCount1, lpString2, cchCount2);
}
#endif


#if (YY_Thunks_Target < __WindowsNT5_1)
#if (YY_Thunks_Target < __WindowsNT6)

// Windows 2000 不支持 LOCALE_INVARIANT 参数特殊处理一下。
// Minimum supported client Windows 2000 Professional [desktop apps only]
// Minimum supported server Windows 2000 Server [desktop apps only]
// 虽然Windows 2000已经支持,但是几个新标记老系统不支持,特殊处理一下。
__DEFINE_THUNK(
kernel32,
24,
Expand All @@ -334,18 +332,30 @@ namespace YY::Thunks
_In_ int cchCount2
)
{
// 网友 海好蓝 提供
const auto _pfnCompareStringW = try_get_CompareStringW();
if (!_pfnCompareStringW)
{
SetLastError(ERROR_NOT_SUPPORTED);
return 0;
}

if (Locale == LOCALE_INVARIANT && IsSupportLOCALE_INVARIANT() == false)
#if (YY_Thunks_Target < __WindowsNT5_1)
// Windows 2000 不支持 LOCALE_INVARIANT 参数特殊处理一下。
// 网友 海好蓝 提供
if (Locale == LOCALE_INVARIANT && internal::GetSystemVersion() < internal::MakeVersion(5, 1))
{
Locale = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
}
#endif

#if (YY_Thunks_Target < __WindowsNT6)
// Windows XP不支持 NORM_LINGUISTIC_CASING
// 网友 海好蓝 反馈
if (internal::GetSystemVersion() < internal::MakeVersion(6, 0))
{
dwCmpFlags &= ~NORM_LINGUISTIC_CASING;
}
#endif

return _pfnCompareStringW(Locale, dwCmpFlags, lpString1, cchCount1, lpString2, cchCount2);
}
Expand Down

0 comments on commit 5652ff5

Please sign in to comment.