Strings Delphi

Function ReplaceCharInString(S,OldChar,NewChar :String): String;
Var
NewString : String;
i : Integer;
L : Integer;
C : String;
Begin
Result := '';
NewString := '';
L := Length(S);
If L = 0 Then Exit;
If Pos(UpperCase(OldChar),UpperCase(S)) = 0 Then
Begin
Result := S;
Exit;
End;
For i := 1 To L Do
Begin
C := SubStr(S,i,1);
If UpperCase(C) = UpperCase(OldChar) Then
Begin
NewString := NewString + NewChar;
End
Else
Begin
NewString := NewString + C;
End;
End;
Result := NewString;
End;