部分代码 cMemo.lines.clear; width:=iniFile.ReadInteger('Setting','cMemo_num',3); temp:= DataM.ADOQuery1.FieldByName('CMemo').asstring; len:=strlen(pChar(temp)); i:=0; CMemo.Lines.text:=''; while i<len-1 do begin temp1:=''; for j:=1 to width do begin temp1:=copy(temp,i,1); i:=i+1; end; CMemo.lines.Add(temp1); end;
procedure TfrmOAFWSongShenrpt.QRDBText1Print(sender: TObject; var Value: String); var str,str1 : string; strA: PChar; charA: char; Num: Integer; num1:Integer; begin Num := 0; Num1 := 0; str1 := ''; str := Value; strA := PChar(str); while (Num<Length(Str)) do begin charA:=StrA[Num]; if ((CharA=#13) or (CharA=#10)) then begin inc(Num); Num1 := 0; str1 := str1+CharA; end else if CharA>Chr(128) then begin str1 := str1+CharA; str1 := str1+StrA[Num+1]; Num := Num+2; Num1 := Num1+2; end else begin Num := Num+1; Num1 := Num1+1; str1 := str1+CharA; end; if Num1>=62 then begin str1 := str1+#13+#10; Num1 := 0; end; end; Value := str1; end; 主要就是根据中文的ord后是大于128的,而英文是小于128的
cMemo.lines.clear;
width:=iniFile.ReadInteger('Setting','cMemo_num',3);
temp:= DataM.ADOQuery1.FieldByName('CMemo').asstring;
len:=strlen(pChar(temp));
i:=0;
CMemo.Lines.text:='';
while i<len-1 do
begin
temp1:='';
for j:=1 to width do
begin
temp1:=copy(temp,i,1);
i:=i+1;
end;
CMemo.lines.Add(temp1);
end;
var Value: String);
var
str,str1 : string;
strA: PChar;
charA: char;
Num: Integer;
num1:Integer;
begin
Num := 0;
Num1 := 0;
str1 := '';
str := Value;
strA := PChar(str);
while (Num<Length(Str)) do
begin
charA:=StrA[Num];
if ((CharA=#13) or (CharA=#10)) then
begin
inc(Num);
Num1 := 0;
str1 := str1+CharA;
end
else if CharA>Chr(128) then
begin
str1 := str1+CharA;
str1 := str1+StrA[Num+1];
Num := Num+2;
Num1 := Num1+2;
end
else
begin
Num := Num+1;
Num1 := Num1+1;
str1 := str1+CharA;
end;
if Num1>=62 then
begin
str1 := str1+#13+#10;
Num1 := 0;
end;
end;
Value := str1;
end;
主要就是根据中文的ord后是大于128的,而英文是小于128的