Discussion:
CRLF en string
(too old to reply)
Moore
2008-05-09 13:27:56 UTC
Permalink
I have a tcp server which sends the string '19DIM R' (with space) to a tcp client, this one receives it as '19DIM'#$D#$A'R',
in fact i see this when debugging because in a GUI appear 2 vertical dashes in the place of the space,
I don't want to use the StringReplace function as i send many strings in a stringlist,

How to correct this?
Remy Lebeau (TeamB)
2008-05-09 16:26:26 UTC
Permalink
Post by Moore
I have a tcp server which sends the string '19DIM R' (with space) to a tcp
client
How is it sending exactly? Please show the actual code.


Gambit
Moore
2008-05-12 06:30:52 UTC
Permalink
I send it like this:

AContext.Connection.IOHandler.WriteLn('LINPUTS ' + slLInputs.CommaText);

the string list contains some strings that have space, which is replaced by a crlf caracter it seems when i show the contents in a listbox or other control..
Post by Remy Lebeau (TeamB)
How is it sending exactly? Please show the actual code.
Gambit
Remy Lebeau (TeamB)
2008-05-12 17:19:46 UTC
Permalink
You did not show how slLInputs is being filled in beforehand.
Post by Moore
the string list contains some strings that have space
Please show the actual values.
Post by Moore
which is replaced by a crlf caracter it seems when i show the
contents in a listbox or other control..
The TStrings.CommaText property does not replace spaces with CRLF, and
neither does Indy. Something else has to be going on in your code to do
that separately before Indy gets the data.


Gambit
Moore
2008-05-13 07:56:20 UTC
Permalink
stmLInputs := TStringStream.Create(S);
slInputs := TStringList.Create;
slInputs.StrictDelimiter := True;
try
ftpProxy.Connect(SrvName);
ftpProxy.ChangeDir('/home/config/matrix');
ftpProxy.Get('/home/config/matrix/linputs.cfg',stmLInputs);
ftpProxy.Disconnect;
slLInputs.Text := stmLInputs.DataString;
some code ...
Memo1.Lines.Add(slLInputs[i]);

ASender.Context.Connection.IOHandler.WriteLn('LINPUTS ' + slLInputs.CommaText);

The memo control shows the list items correctly..
thnx for help..
Post by Remy Lebeau (TeamB)
Please show the actual values.
Remy Lebeau (TeamB)
2008-05-13 09:14:40 UTC
Permalink
Post by Moore
stmLInputs := TStringStream.Create(S);
<snip>

There is nothing in that code can can be causing Indy to send CRLFs. But
you did not answer my earlier question - what does slLInputs *actually
contain*? What are the actual string values? What does "linputs.cfg"
actually contain?


Gambit
Moore
2008-05-14 06:59:01 UTC
Permalink
an extract of what may contain the cfg file and the string list:

77#OB2 AIB #2#1#132#1#1#1#1#133#2#1#1#1#OB2 AIB L|OB2 AIB R
78#OB3 AIB #2#1#134#1#1#1#1#135#2#1#1#1#OB3 AIB L|OB3 AIB R
79#OB4 AIB#2#1#136#1#1#1#1#137#2#1#1#1#OB4 AIB L|OB4 AIB R
80#OB5 AIB #2#1#138#1#1#1#1#139#2#1#1#1#OB5 AIB L|OB5 AIB R
81#OB6 AIB#2#1#140#1#1#1#1#141#2#1#1#1#OB6 AIB L|OB6 AIB R
82#OB7 AIB#2#1#142#1#1#1#1#143#2#1#1#1#OB7 AIB L|OB7 AIB R
83#OB8 AIB#2#1#144#1#1#1#1#145#2#1#1#1#OB8 AIB L|OB8 AIB R
84#OB9 AIB#2#1#146#1#1#1#1#147#2#1#1#1#OB9 AIB L|OB9 AIB R
85#TIMEAIM#2#2#70#1#1#1#1#71#2#1#1#1#TIMEAIM L|TIMEAIM R
86#YJAIM#2#1#68#1#1#1#1#69#2#1#1#1#YJAIM L|YJAIM R

In fact i am verifying that the text arrives correctly to the client application, the problem seems with the stringlist used to hold it in the client application, i see a LineBreak property of the TStringList but there is no help on it in help of Delphi2007 neither in Delphi7..

"Remy Lebeau \(TeamB\)" <***@no.spam.com> wrote:

But
Post by Remy Lebeau (TeamB)
you did not answer my earlier question - what does slLInputs *actually
contain*? What are the actual string values? What does "linputs.cfg"
actually contain?
Yahoo Serious
2008-06-24 12:44:48 UTC
Permalink
Post by Moore
77#OB2 AIB #2#1#132#1#1#1#1#133#2#1#1#1#OB2 AIB L|OB2 AIB R
It looks to me like you are having a problem with the TStrings.CommaText.
By default it also interprets spaces (and more) as separators, not only
commas. And separators will be converted to CRLF when using the
TStrings.Text.

You could analyze the problem:
Verify the Text (or Count) just before sending, by tracing into
IOHandler.WriteLn (not in your Memo or other source), and just after
receiving by tracing into IOHandler.ReadLn (not after handling by in your
LisBox/Memo or other destination).

Or just try to fix it:
Check the Help to read about quoting TStrings.CommaText, and/or try using
TStrings.StrictDelimiter (D2006 and up).

Yahoo.

NB: TStrings.SetCommaText will overwrite Delimiter and QuoteChar (which are
also used by DelimitedText).

Moore
2008-05-14 07:33:28 UTC
Permalink
I resolved it in the client this way :

ASender.Params.LineBreak := #32;

I don't know if it is the correct way but for the moment it functions..
Post by Remy Lebeau (TeamB)
Post by Moore
stmLInputs := TStringStream.Create(S);
<snip>
There is nothing in that code can can be causing Indy to send CRLFs. But
you did not answer my earlier question - what does slLInputs *actually
contain*? What are the actual string values? What does "linputs.cfg"
actually contain?
Gambit
Loading...