Board index » delphi » strange characters at end of memo text?

strange characters at end of memo text?

Hi all, hope someone can help with this.

I am taking contents of a memo, placing them into a string variable and then
allowing the user to edit these via an input box (the text is small). When
the text is displayed in the input box it has 2 thin rectangular characters
on the end, the king that are used for non displaying characters usually.
I'm guessing they relat to carriage return and line feed or something to do
with the memo's formating. How can I get rid of these so that they do not
display? I'd give an example, but the y don't survive a copy and paste.

--
~~~~~~~~~~~~~
?raig ?eynolds
~~~~~~~~~~~~~
Just because this is never going to work is no reason to be negative!

 

Re:strange characters at end of memo text?


Quote
Craig Reynolds wrote:
> I am taking contents of a memo, placing them into a string
> variable and then allowing the user to edit these via an
> input box (the text is small). When the text is displayed
> in the input box it has 2 thin rectangular characters on the
> end, the king that are used for non displaying characters usually.
> [...]

If the memo's contents are of just one line, you can use the
TrimRight() function from SysUtils since this removes all
trailing spaces and control characters from the string.

-ThomasN

Re:strange characters at end of memo text?


Quote
"Craig Reynolds" <reynoldscra...@hotmail.com> wrote in message

news:3b3dd108$0$17826@echo-01.iinet.net.au...

Quote
> Hi all, hope someone can help with this.

> I am taking contents of a memo, placing them into a string variable and
then
> allowing the user to edit these via an input box (the text is small). When
> the text is displayed in the input box it has 2 thin rectangular
characters
> on the end, the king that are used for non displaying characters usually.
> I'm guessing they relat to carriage return and line feed or something to
do
> with the memo's formating. How can I get rid of these so that they do not
> display? I'd give an example, but the y don't survive a copy and paste.

Likely the characters are cr/lf. You can remove them with

j := 1;
for i := 1 to Length (s) do
    begin
    if not (s [i] in [#10, #13])
    then begin
        s [j] := s[i];
        inc (j);
        end;
    end;
SetLength (s, j - 1);

Depending on your text, you may not want to simply strip them, but replace
them with blanks.

Re:strange characters at end of memo text?


Thanks for the solutions, they solved the problem.

--
~~~~~~~~~~~~~
?raig ?eynolds
~~~~~~~~~~~~~
Just because this is never going to work is no reason to be negative!

Quote
"Craig Reynolds" <reynoldscra...@hotmail.com> wrote in message

news:3b3dd108$0$17826@echo-01.iinet.net.au...
Quote
> Hi all, hope someone can help with this.

> I am taking contents of a memo, placing them into a string variable and
then
> allowing the user to edit these via an input box (the text is small). When
> the text is displayed in the input box it has 2 thin rectangular
characters
> on the end, the king that are used for non displaying characters usually.
> I'm guessing they relat to carriage return and line feed or something to
do
> with the memo's formating. How can I get rid of these so that they do not
> display? I'd give an example, but the y don't survive a copy and paste.

> --
> ~~~~~~~~~~~~~
> ?raig ?eynolds
> ~~~~~~~~~~~~~
> Just because this is never going to work is no reason to be negative!

Other Threads