System.SysUtils.SameStr

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

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

C++

extern DELPHI_PACKAGE bool __fastcall SameStr(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 with case sensitivity.

SameStr compares S1 and S2 and returns True if they are identical. SameStr is 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 SameStr 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(SameStr(c1, c2, loUserLocale), true));  
  
  c1 := 'p'+char(6)+'p';
  c2 := 'p'+char(31)+'p';
  showmessage(BoolToStr(SameStr(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