LazUtf8: implement Utf8 versions of LeftStr and RightStr.

git-svn-id: trunk@43348 -
This commit is contained in:
bart 2013-11-01 17:40:11 +00:00
parent 66f965d74c
commit 2eb279e6e1

View File

@ -85,7 +85,9 @@ function Utf8AddCharR(AUtf8Char: Utf8String; const S: Utf8String; N: Integer): U
function UTF8PadLeft(const S: Utf8String; const N: Integer; const AUtf8Char: Utf8String = #32): Utf8String;
function UTF8PadRight(const S: Utf8String; const N: Integer; const AUtf8Char: Utf8String = #32): Utf8String;
function UTF8PadCenter(const S: Utf8String; const N: Integer; const AUtf8Char: Utf8String = #32): Utf8String;
function Utf8LeftStr(const AText: String; const ACount: Integer): String;
function Utf8RightStr(const AText: String; const ACount: Integer): String;
//Utf8 version of MidStr is just Utf8Copy with same parameters, so it is not implemented here
type
TUTF8TrimFlag = (
@ -2588,6 +2590,22 @@ begin
Result := S;
end;
function Utf8LeftStr(const AText: String; const ACount: Integer): String;
begin
Result := Utf8Copy(AText,1,ACount);
end;
function Utf8RightStr(const AText: String; const ACount: Integer): String;
var
j,l:integer;
begin
l := Utf8Length(AText);
j := ACount;
if (j > l) then j := l;
Result := Utf8Copy(AText,l-j+1,j);
end;
function UTF8Trim(const s: string; Flags: TUTF8TrimFlags): string;