删除行首行尾空格:(包括中文空格)
function DeleteTerminalBlank(const Line:string):string;
var
oldLine:string;
SelPos1,SelPos2:integer;
b1,b2:boolean;
Begin
if(Line = '') then
begin
Result := '';
exit;
end;
OldLine := Line;
SelPos1 := Pos(' ',OldLine);
SelPos2 := Pos(' ',OldLine);
b1 := (SelPos1 = 1);
b2 := (SelPos2 = 1);
while(b1 or b2) do
Begin
if(b1) then Delete(OldLine,1,1)
else Delete(OldLine,1,2);
SelPos1 := Pos(' ',OldLine);
SelPos2 := Pos(' ',OldLine);
b1 := (SelPos1 = 1);
b2 := (SelPos2 = 1);
end;
b1 := OldLine[Length(OldLine)] = ' ';
if(Length(OldLine) > 2) then b2 := Copy(OldLine,Length(OldLine) - 1,2) = ' '
else b2 := false;
while((b1 or b2) and (Length(OldLine) <> 0)) do
Begin
if(b1) then Delete(OldLine,Length(OldLine),1)
else Delete(OldLine,Length(OldLine) - 1,2);
b1 := OldLine[Length(OldLine)] = ' ';
if(Length(OldLine) > 2) then b2 := Copy(OldLine,Length(OldLine) - 1,2) = ' '
else b2 := false;
end;
Result := OldLine;
end;
乱码的问题,那位大侠知道怎么回事?会不会是因为RichEdit支持RTF格式引起的?