[+] AuCodepointsIsEqualIgnoreCase

This commit is contained in:
Reece Wilson 2024-06-14 14:32:12 +01:00
parent cd5dec55b2
commit a40017ef86

View File

@ -12,13 +12,14 @@
Implements: AuStringContains, AuEndsWith, AuStartsWith, AuReplaceAll, AuSplitString (views), AuSplitStringLegacy (returns an array of strings instead of views) Implements: AuStringContains, AuEndsWith, AuStartsWith, AuReplaceAll, AuSplitString (views), AuSplitStringLegacy (returns an array of strings instead of views)
AuToLower(char), AuToUpper(char), AuToLower(view), AuToUpper(view). AuToLower(char), AuToUpper(char), AuToLower(view), AuToUpper(view).
Implements: AuCodepointsTransform, AuCodepointsTransformASCIIOp, AuCodepointsToLower, AuCodepointsToUpper, Implements: AuCodepointsTransform, AuCodepointsTransformASCIIOp, AuCodepointsForEach, AuCodepointsToLower, AuCodepointsToUpper,
AuCodepointsCount, AuCodepointsNextLength, AuCodepointsDecode, AuCodepointsEncodeInto, AuCodepointsCount, AuCodepointsNextLength, AuCodepointsDecode, AuCodepointsEncodeInto,
AuCodepointsGetByteOffset(CodepointOffset_t),AuCodepointsGetByteLength(CodepointOffset_t), AuCodepointsGetByteOffset(CodepointOffset_t),AuCodepointsGetByteLength(CodepointOffset_t),
AuCodepointsFindByteOffset[Unsafe], AuCodepointsFindCodepointOffset(view, CodepointOffset_t), AuCodepointsFindCodepointOffset(CodepointByteOffset_t), AuCodepointsFindByteOffset[Unsafe], AuCodepointsFindCodepointOffset(view, CodepointOffset_t), AuCodepointsFindCodepointOffset(CodepointByteOffset_t),
AuCodepointsContains, AuCodepointsContains,
AuCodepointsReplaceAll, AuCodepointsSplitString (views), AuCodepointsReplaceAll, AuCodepointsSplitString (views),
AuCodepointsFindPreviousValidByteOffsetFromOffset, AuCodepointsFindPreviousValidByteOffsetFromByteOffset AuCodepointsFindPreviousValidByteOffsetFromOffset, AuCodepointsFindPreviousValidByteOffsetFromByteOffset
AuCodepointsIsEqualIgnoreCase
For translating between locales (including utf8-32), defer to AuLocale (Aurora::Locale) in the Aurora Runtime. For translating between locales (including utf8-32), defer to AuLocale (Aurora::Locale) in the Aurora Runtime.
***/ ***/
@ -534,6 +535,73 @@ static bool AuCodepointsForEach(T op, const AuROString &in)
return true; return true;
} }
static bool AuCodepointsIsEqualIgnoreCase(const AuROString &inA,
const AuROString &inB)
{
if (inA.size() !=
inB.size())
{
return false;
}
if (inA.empty())
{
return true;
}
const char *pItr = inA.data();
const char *pItr2 = inB.data();
const char *pEnd = pItr + inA.length();
while (pItr < pEnd)
{
AuUInt32 c {};
if ((c = *pItr) <= 0x7FU)
{
if (AuToLower(c) != AuToLower(*pItr2))
{
return false;
}
++pItr2;
++pItr;
}
else
{
AuUInt32 nby {};
if ((*pItr & 0xC0U) != 0xC0U)
{
return AuMemcmp(pItr, pItr2, pEnd - pItr) == 0;
}
for (AuUInt8 b = *pItr; (b & 0x80U) != 0; b <<= 1, ++nby)
{
}
if (nby > kAuCodepointUTF8MaxBytes)
{
return AuMemcmp(pItr, pItr2, pEnd - pItr) == 0;
}
if (AuUInt(pEnd - pItr) < AuUInt(nby))
{
return AuMemcmp(pItr, pItr2, pEnd - pItr) == 0;
}
if (AuMemcmp(pItr, pItr2, nby) != 0)
{
return false;
}
pItr += nby;
pItr2 += nby;
}
}
return true;
}
static auline CodepointByteOffset_t AuCodepointsGetByteOffset(const AuROString &in, static auline CodepointByteOffset_t AuCodepointsGetByteOffset(const AuROString &in,
CodepointOffset_t uCodepointIndex) CodepointOffset_t uCodepointIndex)
{ {