2

I might have overlooked something, but it seems that there is no built-in function like:

var
  B: Boolean;
  S: string;
begin
  S := 'Test';
  B := S.SameText('TEST');
  Assert(B);
end;

.NET has a three parameter version for Equals:

string.Equals(S, "TEST", StringComparison.OrdinalIgnoreCase);

The two versions I can come up with is:

// Ordinal?
string.CompareText(S, 'TEST') = 0
// Culture specific
string.Compare(S, 'TEST', True, TLanguages.UserDefaultLocale)

What puts me off here is that I have to compare to 0, instead of good old SameText:

SameText(S, 'TEST')

Did Embarcadero overlook to provide a SameText on TStringHelper?

MartynA
  • 30,454
  • 4
  • 32
  • 73
Jens Mühlenhoff
  • 14,565
  • 6
  • 56
  • 113

2 Answers2

4

Did Embarcadero overlook to provide a SameText on TStringHelper?

Yes.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
0

AnsiCompareText - Compares strings based on the current locale without case sensitivity.

Deepak Dhyani
  • 91
  • 1
  • 3