关于delphi字符长度的问题?

来源:百度知道 编辑:UC知道 时间:2024/05/09 03:44:29
我想输出字符串和长度限定在10汉字之内
如果不够10个字的话用空格代替
如果写这段代码
大虾帮忙!!!1

首先在delphi2009之前的版本应该是
s:=format('%20s',[s]);
因为一个汉字是2个ascii字符.
2009以后的版本默认是Unicode编码.
s:=format('%10s',[s]);

if length(str)<10 then
begin
str:=
end;

s:=Format('%10s',[s]);