/* String comparison without regard to case for a limited number of characters. */
INTN StrniCmp(IN CONST CHAR16 *Source, IN CONST CHAR16 *Target, IN CONST UINTN Count)
/* String comparison without regard to case for a limited number of characters. */
INTN StrniCmp(IN CONST CHAR16 *Source, IN CONST CHAR16 *Target, IN CONST UINTN Count)
{
  CHAR16  *SourceCopy;
  CHAR16  *TargetCopy;
  UINTN   SourceLength;
  UINTN   TargetLength;
  INTN    Result;
  if (Count == 0) {
    return 0;
  }
  SourceLength = StrLen (Source);
  TargetLength = StrLen (Target);
  SourceLength = MIN (SourceLength, Count);
  TargetLength = MIN (TargetLength, Count);
  SourceCopy   = AllocateCopyPool ((SourceLength + 1) * sizeof (CHAR16), Source);
  if (SourceCopy == NULL) {
    return -1;
  }
  TargetCopy = AllocateCopyPool ((TargetLength + 1) * sizeof (CHAR16), Target);
  if (TargetCopy == NULL) {
    FreePool (SourceCopy);
    return -1;
  }
  SourceCopy[SourceLength] = L'\0';
  TargetCopy[TargetLength] = L'\0';
  Result                   = gUnicodeCollation->StriColl (gUnicodeCollation, SourceCopy, TargetCopy);
  FreePool (SourceCopy);
  FreePool (TargetCopy);
  return Result;
}