[2005.7.25]DelimitedText

一段代码,可以把QQ里边复制出来的文字中小黑方块变成正常的换行

procedure ConvertQQMsg(Lines: TMemo);
var
  TmpStrList: TStrings;
begin
  TmpStrList := TStringList.Create;
  try
    TmpStrList.Text := Lines.Lines.Text;
    TmpStrList.Delimiter := #13;
    Lines.Lines.DelimitedText := TmpStrList.DelimitedText;
  finally
    TmpStrList.Free;
  end;
end;

研究半天,没看懂那个DelimitedText是什么意思.........

这格式帮助里边的解释

Descriptio

Use DelimitedText to get or set all the strings in the TStrings object in a single string.

When reading DelimitedText, the resulting value delimits individual strings in two ways: each string is surrounded (before and after) by the quote character specified by the QuoteChar property. In addition, individual strings are separated by the character specified by the Delimiter property.

When writing DelimitedText, individual strings must be separated using QuoteChar at both ends, using Delimiter as a separator, or using both these methods.

Note: CommaText is the same as the DelimitedText property when Delimiter is ',' and QuoteChar is '"'.

大概是DelimitedText在Read时候会把TSTringList里边的Text的多行文字按两种方式组合,一是用quoteChar里边的东西把每行东西 二是用Delimiter里边的东西把每行分开.....但是实际试验似乎不是这样的..........

拿这几句try了一下

Memo1.Lines.Delimiter:=';';
Memo1.Lines.QuoteChar:='~';
Memo2.Lines.Add(memo1.Lines.DelimitedText)

大概的结论:

   换行会被;隔开,但是最后一行除外  如果这行有; 那么这行会被~引起来(包括;) 如果这样有~ 那么这行会被n个~成n+1段,每段用~引起来

write应该就是反过来

结论是 这东西用于把单行文字变成多行文字或者相反

那段代码的意思是,qq复制下来的东西是以#13为分割的单行文字,所以把tem的delimited设置成#13

然后再转成多行

不过总觉得那段代码是有问题的,Read"TmpStrList.DelimitedText"的时候会自动在字符串两边加上QuoteChar.........

研究了半天

Memo2.Lines.Delimiter:=#65;
Memo2.Lines.DelimitedText:=Memo1.Lines.Text;

这个倒是可以把'A'改成换行

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值