Skip to main content

SameText

Function SameText( const S1, S2 : string) : Boolean

Example

procedure ScriptEvent(var Value: variant);
begin
Value := SameText('Ready', 'READY');
end;

Usage

SameText reports whether two strings are equal without case sensitivity using Velox's ordinal text rules.

Parameters

NameTypeDescription
S1string, constFirst complete string.
S2string, constSecond complete string.

Returns

True when the strings have equal length and every UTF-16 code unit compares equal after ASCII a through z are folded to uppercase; otherwise False.

Behaviour

Two empty strings are same. Case differences within the ASCII alphabet are ignored. Length, whitespace, punctuation, embedded null code units and all non-ASCII code-unit differences remain significant.

Errors

There is no normal content-dependent exception path. Values that cannot convert to string can fail before entry.

Usage notes

This routine is appropriate for case-insensitive ASCII protocol tokens. Choose an explicitly normalised and locale-defined comparison for international natural-language matching.

Additional Technical Info

SameText compares two complete strings without case sensitivity under Delphi's ordinal comparison rules. It is equivalent to testing whether the exposed CompareText result is zero.

The example returns True. It is source-reviewed and is not executed by the documentation workflow.

Implementation

Velox binds directly to the two-parameter overload of System.SysUtils.SameText. Current Delphi source returns CompareText(S1, S2) = 0. That overload performs ordinal comparison and case-folds only ASCII lowercase letters. Velox does not expose the overload that accepts TLocaleOptions.

Edge cases and quirks

  • This overload is ordinal, not user-locale comparison. It intentionally differs from MatchText, whose current terminal path uses AnsiSameText and the user-default locale for non-ASCII text on Windows.
  • Non-ASCII case pairs such as accented letters are not generally folded by this implementation.
  • Unicode normalisation is not performed. Canonically equivalent strings with different code-unit sequences can compare different.
  • Comparison uses UTF-16 code units rather than grapheme clusters.
  • The name does not imply trimming: 'READY ' and 'ready' are different.

Side effects

None.

Performance and concurrency

Comparison is linear in the shorter string and can stop at the first unequal code unit. Identical managed-string references take a fast path. There is no allocation or mutable shared state.

Related entries

  • CompareText returns the underlying ordinal relationship.
  • MatchText searches a candidate array using a different locale-aware terminal path.
  • SameHash performs case-sensitive non-empty equality.

External references

Created 2026-07-15