Delphi의 문자열 함수(5) - SysUtils의 Ansi 문자열 함수

2917 단어 Delphi

//          : AnsiSameStr、AnsiSameText
var
  ss,s: AnsiString;
  b: Boolean;
begin
  ss := 'abc';
  s := 'ABC';

  b := AnsiSameStr(ss,s);    {     }
  ShowMessage(BoolToStr(b)); {False}

  b := AnsiSameText(ss,s);   {      }
  ShowMessage(BoolToStr(b)); {True}
end;

 
// : AnsiCompareStr、AnsiCompareText var s1,s2: AnsiString; i: Integer; begin s1 := 'Hello'; s2 := 'hello'; i := AnsiCompareStr(s1,s2); { } ShowMessage(IntToStr(i)); {1} i := AnsiCompareText(s1,s2); { } ShowMessage(IntToStr(i)); {0} { 3 : s1 > s2 : 1 s1 < s2 : -1 s1 = s2 : 0 } end;
// : AnsiCompareFileName var s1,s2: AnsiString; i: Integer; begin s1 := 'c:\temp\2.txt'; s2 := 'c:\temp\1.TXT'; i := AnsiCompareFileName(s1,s2); ShowMessage(IntToStr(i)); {1} { 3 : s1 > s2 : 1 s1 < s2 : -1 s1 = s2 : 0 } end;
// : AnsiUpperCase、AnsiLowerCase var ss,s: AnsiString; begin ss := 'Hello'; s := AnsiUpperCase(ss); ShowMessage(s); {HELLO} s := AnsiLowerCase(ss); ShowMessage(s); {hello} end;
// : AnsiUpperCaseFileName、AnsiLowerCaseFileName var ss,s: AnsiString; begin ss := 'C:\Temp\1.txt'; s := AnsiUpperCaseFileName(ss); ShowMessage(s); {C:\TEMP\1.TXT} s := AnsiLowerCaseFileName(ss); ShowMessage(s); {c:\temp\1.txt} end;
// : AnsiPos var ss,s: AnsiString; i: Integer; begin ss := 'abcdefgcd'; s := 'cd'; i := AnsiPos(s,ss); ShowMessage(IntToStr(i)); {3} end;
// : AnsiQuotedStr var ss,s: AnsiString; begin ss := 'Hello'; s := AnsiQuotedStr(ss, '"'); { 2 , Char } ShowMessage(s); {"Hello"} s := AnsiQuotedStr(ss, '#'); ShowMessage(s); {#Hello#} ss := 'Hello#Hello'; { , } s := AnsiQuotedStr(ss, '#'); ShowMessage(s); {#Hello##Hello#} end;
// : AnsiDequotedStr var ss,s: AnsiString; begin ss := '"Hello"'; s := AnsiDequotedStr(ss, '"'); ShowMessage(s); {Hello} end;

좋은 웹페이지 즐겨찾기