为你写了这样一个function,你试一下:
function InsertEnterKey(OldStr:String):String;
type CharBit = ^char;
var
StrBit : CharBit
BitChar : char;
TmpStr,ReturnStr:string;
icount,iTen:integer;
begin
Result := OldStr;
TmpStr := '';
ReturnStr := '';
iTen := 0
iCount := 1
while iCount <= length(OldStr) do begin
if length(OldStr)-iCount + iTen <= 10 then begin
ReturnStr := ReturnStr + copy(OldStr,iCount,254);
break;
end;
if iTen = 10 then begin
iTen := 0
ReturnStr := ReturnStr + #13+#10;
end;
inc(iTen,1);
TmpStr := copy(OldStr,iCount,1);
StrBit := CharBit(TmpStr);
BitChar := StrBit^;
if ord(BitChar) > 127 then begin
ReturnStr := ReturnStr + copy(OldStr,iCount,2)
//加一个汉字
inc(iCount,2);
end else begin
ReturnStr := ReturnStr + copy(OldStr,iCount,1)
//加一个非汉字字符
inc(iCount,1);
end;
end;
Result := ReturnStr
end;