From 67333e74574e11dded859fed169cbd27b1943c0b Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Sat, 4 Sep 2010 17:09:20 +0200 Subject: New string utility function fpgTrimR() which trims text on right only. --- src/corelib/fpg_stringutils.pas | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/corelib/fpg_stringutils.pas b/src/corelib/fpg_stringutils.pas index f97f1b61..3e54e02b 100644 --- a/src/corelib/fpg_stringutils.pas +++ b/src/corelib/fpg_stringutils.pas @@ -48,6 +48,8 @@ procedure Insert8(const Source: string; var S: string; Index: integer); function fpgCharAt(const s: TfpgString; Index: integer): TfpgChar; function fpgAppendPathDelim(const Path: TfpgString): TfpgString; function fpgRemovePathDelim(const Path: TfpgString): TfpgString; +function fpgTrimR(const AString, ATrim: TfpgString; ACaseSensitive: boolean = false): TfpgString; + implementation @@ -335,5 +337,21 @@ begin Result := Path; end; +function fpgTrimR(const AString, ATrim: TfpgString; ACaseSensitive: boolean): TfpgString; +var + li: integer; +begin + if ACaseSensitive then + li := UTF8Pos(ATrim, AString) + else + li := UTF8Pos(UpperCase(ATrim), UpperCase(AString)); + + if li <> 0 then + Result := UTF8Copy(AString, 1, li - 1) + else + Result := AString; +end; + + end. -- cgit v1.2.3-70-g09d2