summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graemeg@gmail.com>2010-09-04 17:09:20 +0200
committerGraeme Geldenhuys <graemeg@gmail.com>2010-09-04 17:09:20 +0200
commit67333e74574e11dded859fed169cbd27b1943c0b (patch)
tree21e3f7dca02ae4d4cbd1f1e043d5edf8efb0059e
parent25397622e83c98b6680416731795ae83c3a5488f (diff)
downloadfpGUI-67333e74574e11dded859fed169cbd27b1943c0b.tar.xz
New string utility function fpgTrimR() which trims text on right only.
-rw-r--r--src/corelib/fpg_stringutils.pas18
1 files changed, 18 insertions, 0 deletions
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.