Delphi function to convert Result of WrapText to TStringList

I use this function to insert carriage returns on a string so it is nicely formatted for emailing:

  m := WrapText(m, #13#10, ['.',' ',#9,'-'], 60);

The problem is my email client has a 1023 character limit when processing strings. So if the original length of m is greater than 1023, it gets truncated (Note: the email client probably has events to handle this situation, but I think an easier approach is to just feed it strings less than the limit).

I am looking for a " WrapTextToStringList " function like this:

var
  mStringList: TStringList;
begin
  mStringList := WrapTextToStringList(m, #13#10, ['.',' ',#9,'-'], 60);

So say I passed this a 220 character body of an email message. The results would be a string list with approximately 4 entries.

I think this just boils down to creating a function which parses a string at #13#10 into a string list.

Anyone got one?


TStringList already has a built-in method to parse a string at #13#10 into a string list.

MyStringList := TStringList.Create;
MyStringList.Text := MyString;

This will populate the list by parsing the string and creating a new entry in the list whenever it finds a return.

链接地址: http://www.djcxy.com/p/61490.html

上一篇: Delphi VirtualKey转换为WideString

下一篇: Delphi函数将WrapText的结果转换为TStringList