一个比较棘手的问题:当使用TStringList向文本里增加数据时,使用的是回车换行还是换行(100分)

  • 主题发起人 主题发起人 free_dragon
  • 开始时间 开始时间
F

free_dragon

Unregistered / Unconfirmed
GUEST, unregistred user!
function AppendText(TextFile,sData : string):boolean;
var
sl : TStrings;
i : integer;
bIsAdd : boolean;
begin
bIsAdd := false;
sl:=TStringList.Create;
try
sl.LoadFromFile('whitelist.txt');
sl.Add(sData);
bIsAdd := true;
finally
sl.SaveToFile('whitelist.txt');
sl.Free;
end;

Result := bIsAdd;
end;

比如第一次插入的数据是 www.163.com
第二次插入的数据是 www.sohu.com

文本中的内容为
www.163.com
www.sohu.com

...
我想问的是他们用的是“回车换行”还是只用了“换行”

如果我想要只用“换行”如何实现
 
没人回答吗,我自己顶一下
 
回车 #13
换行 #10

回车换行 #13+#10

应该用回车换行
 
相当于回车换行。
 
Lists the strings in the TStrings object as a single string with the individual strings delimited by carriage returns and line feeds.
Delphi syntax:

property Text: string;

C++ syntax:

__property AnsiString Text = {read=GetTextStr, write=SetTextStr};

Description

Use Text to get or set all the strings in the TStrings object in a single string delimited by carriage return, line feed pairs.

When reading Text, the strings in the list will be separated by carriage return and (on Windows) line feed. If any of the strings in the list contain a carriage return (and line feed), the resulting value of Text will appear to contain more strings than is indicated by the Count property.

When setting Text, the value will be parsed by separating into substrings whenever a carriage return or linefeed is encountered. (The two do not need to form pairs).

If the strings in the list contain carriage return or linefeed characters, a less ambiguous format for the strings is available through the CommaText or DelimitedText property.
 
默认是回车换行,只要换行的话看楼上贴出来的属性帮助。
 
问题已解决,谢谢大家!放分了。
 
后退
顶部