The string handling routines in SysUtils handle both UnicodeString and AnsiString types. Within their functional areas, some routines are used for the same purpose, the differences being whether they use a particular criterion in their calculations.
The AnsiStrings unit's functions offer the same capabilities as the SysUtils unit's routines. AnsiStrings functions provide better performance for AnsiString than SysUtils functions, because SysUtils functions convert an AnsiString to a UnicodeString. AnsiStrings functions work only with AnsiString, so there is no conversion.
The following tables list these routines by these functional areas:
String length routines:
Routine |
Uses locale settings |
Supports MBCS |
Returns |
yes |
yes |
Number of elements in string. Does not account for MBCS or Unicode surrogate pair "characters". | |
yes |
yes |
Number of bytes required to represent type or variable. |
Note that Length and SizeOf give different results for all strings except for short strings. SizeOf equals the number of bytes in a pointer, since non-short strings are pointers.
String comparison routines:
Routine |
Case-sensitive |
Uses locale settings |
Supports MBCS |
AnsiStrings.AnsiCompareStr SysUtils.AnsiCompareStr |
yes |
yes |
yes |
AnsiStrings.AnsiCompareText SysUtils.AnsiCompareText |
no |
yes |
yes |
AnsiStrings.AnsiCompareFileName SysUtils.AnsiCompareFileName |
no |
yes |
yes |
AnsiStrings.AnsiMatchStr StrUtils.AnsiMatchStr |
yes |
yes |
yes |
AnsiStrings.AnsiMatchText StrUtils.AnsiMatchText |
no |
yes |
yes |
AnsiStrings.AnsiContainsStr StrUtils.AnsiContainsStr |
yes |
yes |
yes |
AnsiStrings.AnsiContainsText StrUtils.AnsiContainsText |
no |
yes |
yes |
AnsiStrings.AnsiStartsStr StrUtils.AnsiStartsStr |
yes |
yes |
yes |
AnsiStrings.AnsiStartsText StrUtils.AnsiStartsText |
no |
yes |
yes |
AnsiStrings.AnsiEndsStr StrUtils.AnsiEndsStr |
yes |
yes |
yes |
AnsiStrings.AnsiEndsText StrUtils.AnsiEndsText |
no |
yes |
yes |
AnsiStrings.AnsiEndsStr StrUtils.AnsiEndsStr |
yes |
yes |
yes |
AnsiStrings.AnsiIndexText StrUtils.AnsiIndexText |
no |
yes |
yes |
AnsiStrings.CompareStr SysUtils.CompareStr |
yes |
no |
no |
AnsiStrings.CompareText SysUtils.CompareText |
no |
no |
no |
no |
no |
no |
Case conversion routines:
Routine |
Uses locale settings |
Supports MBCS |
AnsiStrings.AnsiLowerCase SysUtils.AnsiLowerCase |
yes |
yes |
AnsiStrings.AnsiUpperCaseFileName SysUtils.AnsiUpperCaseFileName |
yes |
yes |
AnsiStrings.AnsiUpperCase SysUtils.AnsiUpperCase |
yes |
yes |
AnsiStrings.LowerCase SysUtils.LowerCase |
no |
no. Works for A to Z only, not European accented characters. |
AnsiStrings.UpperCase SysUtils.UpperCase |
no |
no. Works for a to z only, not European accented characters. |
Routine |
Case-sensitive |
Supports MBCS |
NA |
yes | |
AnsiStrings.AnsiQuotedStr SysUtils.AnsiQuotedStr |
NA |
yes |
AnsiStrings.AnsiReplaceStr StrUtils.AnsiReplaceStr |
yes |
yes |
AnsiStrings.AnsiReplaceText StrUtils.AnsiReplaceText |
no |
yes |
AnsiStrings.StringReplace SysUtils.StringReplace |
optional by flag |
yes |
AnsiStrings.ReverseString StrUtils.ReverseString |
NA |
no |
AnsiStrings.StuffString StrUtils.StuffString |
NA |
no |
NA |
no | |
yes |
yes | |
AnsiStrings.Trim SysUtils.Trim |
NA |
yes |
AnsiStrings.TrimLeft SysUtils.TrimLeft |
NA |
yes |
AnsiStrings.TrimRight SysUtils.TrimRight |
NA |
yes |
NA |
yes |
Sub-string routines:
Routine |
Case-sensitive |
Supports MBCS |
NA |
yes | |
AnsiStrings.AnsiPos SysUtils.AnsiPos |
yes |
yes |
AnsiStrings.IsDelimiter SysUtils.IsDelimiter |
yes |
yes |
AnsiStrings.IsPathDelimiter SysUtils.IsPathDelimiter |
yes |
yes |
AnsiStrings.LastDelimiter SysUtils.LastDelimiter |
yes |
yes |
NA |
no | |
NA |
no | |
NA |
no | |
AnsiStrings.QuotedStr SysUtils.QuotedStr |
no |
no |
NA |
yes |
String information routines (in System):
Routine |
Returns |
System.StringCodePage |
Code page |
System.StringElementSize |
Element size |
System.StringRefCount |
Reference count |
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|