TStringHelper.Starts/EndsWith
<h3><details><summary>Original Reporter info from Mantis: <small>BeniBela @benibela</small></summary><small>
- **Reporter name:** Benito van der Zander
</small></details></h3>
## Description:
the string helper looks quite useful, but let's take a close look
> 1297 function TStringHelper.StartsWith(const AValue: string; IgnoreCase: Boolean<br/>
> 1298 ): Boolean;<br/>
> 1299 Var<br/>
> 1300 L : Integer;<br/>
> 1301 begin<br/>
> 1302 L:=System.Length(AValue);
length returns sizeint nowadays, not integer. But the string helper has integer everywhere. That is not going to work with longer strings...
> 1303 Result:=L>0;<br/>
> 1304 if Result then
So no string starts with an empty string? Would it not make more sense if every string starts with an empty string?
> 1305 if IgnoreCase then<br/>
> 1306 Result:=StrLiComp(PChar(AValue),PChar(Self),L)=0<br/>
> 1307 else<br/>
> 1308 Result:=StrLComp(PChar(AValue),PChar(Self),L)=0
This stops the comparison on #0 chars.
Is that behavior supposed to be Delphi compatible or is the function just completely broken?
On the other hand endsWith handles #0, but makes an unnecessary copy
> 567 S:=system.Copy(Self,Length-L+1,L);<br/>
> 568 Result:=system.Length(S)=L;<br/>
> 569 if Result then<br/>
> 570 if IgnoreCase then<br/>
> 571 Result:=CompareText(S,AValue)=0<br/>
> 572 else<br/>
> 573 Result:=S=AValue;
## Mantis conversion info:
- **Mantis ID:** 33559
- **Version:** 3.1.1
- **Fixed in version:** 3.1.1
- **Fixed in revision:** 38769 (#e4ef17b5c09c79ede8325e697f117e96ce845025)
- **Target version:** 3.2.0
issue