System.SysUtils.SameStr

提供: RAD Studio API Documentation
移動先: 案内検索

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 */;

プロパティ

種類 可視性 ソース ユニット
function public
System.SysUtils.pas
System.SysUtils.hpp
System.SysUtils System.SysUtils

説明

2 つの文字列を大文字/小文字を区別して順序値で比較します。


SameStrS1S2 を比較し、両者が同一であれば True を返します。SameStr は大文字/小文字を区別し、現在のロケールには影響されません。

メモ: OSX、iOS、Android の各プラットフォームでは、LocaleOptions パラメータの値として loUserLocale を使用する場合、制御文字(文字コードが #00 から #31 までのもの)はすべて、SameStr による比較では同じ文字と見なされます。

 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;

どちらの例でも、結果は、Windows プラットフォームの場合は False になり、OSX、iOS、Android の各プラットフォームの場合は True になります。

関連項目