Fastreport 中文换行乱码解决

FASTREPORT中MEMO的wordwrap设为True,使文本自动换行,但当最后一个字为中文时总是出现乱码。怎样才能使最后的字为中文且剩下文本区不足两格时自动换行,避免出现乱码?

主要改fr_class.pas中的wrapline过程,其中有一段:
else if s[last] = then
OutLine(Copy(s, beg, last - beg)) else
OutLine(Copy(s, beg, last - beg + 1));//造成乱码的根本原因
改为
else if s[last] = then
OutLine(Copy(s, beg, last - beg)) else
if ByteType(s,last) = mbLeadByte then //判断是否是汉字字节
OutLine(Copy(s, beg, last - beg ))
else
OutLine(Copy(s, beg, last - beg + 1));
后面的
LoopPos := cur;
beg := last + 1; last := beg;
要改为:
LoopPos := cur;
if ByteType(s,last) = mbLeadByte then
begin
beg := last ; last := beg;
end
else
begin
beg := last + 1; last := beg;
end;
参照http://tian.yeah.net的 fastreport2.41c
posted @ 2009-08-29 10:51  毛小毛  阅读(4143)  评论(0编辑  收藏  举报