String Manipulation

The following functions work exactly like "AnsiUpperCase/AnsiLowerCase", but they're much faster:

function UpChar  (const c: char  ) : char;
function UpStr   (const s: string) : string;
function LowChar (const c: char  ) : char;
function LowStr  (const s: string) : string;

The function "FillStr" makes sure that a string has at least the length "minLen". If necessary, the string is filled up with the "fillChar". If "minLen" is negative, the string is filled at the end, otherwise at the beginning.

function FillStr (str      : string;
                  minLen   : integer;
                  fillChar : char = ' ') : string;

// Examples:
FillStr('127',  10, '0')  ->  '0000000127'
FillStr('0.5', -10, '0')  ->  '0.50000000'

The following functions search through the whole "str" and replace the fragment "replaceThis" every time it occurs "withThis". The replacement can be done recursively, if you wish. That means, that the replaced string fragments are checked again. "ReplaceStr" searches case sensitively, while "ReplaceText" searches case insensitively.

function ReplaceStr  (var str     : string;
                      replaceThis : string;
                      withThis    : string;
                      replaceSelf : boolean = false) : boolean;
function ReplaceText (var str     : string;
                      replaceThis : string;
                      withThis    : string;
                      replaceSelf : boolean = false) : boolean;

// Examples:
ReplaceStr('Funnyny.', 'Vunny', 'Fun'        )  ->  'Funnyny.' / false
ReplaceStr('Funnyny.', 'Funny', 'Fun'        )  ->  'Funny.'   / true
ReplaceStr('Funnyny.', 'Funny', 'Fun',   true)  ->  'Fun.'     / true
ReplaceStr('Fun.',     'Fun',   'Funny'      )  ->  'Funny.'   / true
ReplaceStr('Fun.',     'Fun',   'Funny', true)  ->  endless loop