System.SysUtils.SameText

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function SameText(const S1, S2: string): Boolean;
function SameText(const S1, S2: string; LocaleOptions: TLocaleOptions): Boolean;

C++

extern DELPHI_PACKAGE bool __fastcall SameText(const System::UnicodeString S1, const System::UnicodeString S2)/* overload */;

Properties

Type Visibility Source Unit Parent
function public
System.SysUtils.pas
System.SysUtils.hpp
System.SysUtils System.SysUtils

Description

Compares two strings by ordinal value without case sensitivity.

SameText compares S1 and S2 and returns True if they are equal. SameText is not case-sensitive and is not affected by the current locale.

Note: On the OSX, iOS and Android platforms all control characters (character codes are between #31 and #00) are considered as the same character in the SameText comparison if we use loUserLocale as value for the LocaleOptions parameter.

Example

procedure TForm1.Button1Click(Sender: TObject);
var
  c1, c2: string;
begin
  c1 := char(6);
  c2 := char(31);
  showmessage(BoolToStr(SameText(c1, c2, loUserLocale), true));  
  
  c1 := 'p'+char(6)+'p';
  c2 := 'p'+char(31)+'p';
  showmessage(BoolToStr(SameText(c1, c2, loUserLocale), true));  
end;

In both examples, the result will be False for the Windows platform, and True for the OSX, iOS and Android platforms.


See Also