Solved

How to remove the newline charecter from the String

Posted on 2000-05-09
7
181 Views
Last Modified: 2010-08-05
A wideString str contains a string with a newline charecter(Enter key ).
I am trying to copy the WideString value to String variable. It is copying #$D#$A charecters in place of the enter key or new line charecter. How to remove this from the String.
0
Comment
Question by:kiru
  • 3
  • 2
  • 2
7 Comments
 
LVL 5

Accepted Solution

by:
TheNeil earned 100 total points
Comment Utility
Do the copy as before and then check every character in the String:

TempStr := WideStr;
NormalStr := '';
FOR n := 1 TO Length(TempStr)
DO
  IF NOT(TempStr[n] IN [#10, #13])
  THEN
    NormalStr := NormalStr + TempStr[n];

Not the most elegant of solutions but it works.

The Neil =:)
0
 

Author Comment

by:kiru
Comment Utility
Edited text of question.
0
 
LVL 10

Expert Comment

by:Lischke
Comment Utility
Hi kiru,

I'm not sure if removing the newline/linefeed combination is what you really want. You should distinct between the enter key (which is just a key and can be interpreted in different ways) and the NL/LF combination, which CAN be the result of pressing the enter key (but must not).

You wrote that copying the wide string to an ANSI string copies NL/LF instead of enter key. This makes no sense, as there's no line break character yet in the target string which could be replaced by NL/LF. So my assumption is that you have NL/LF in your wide string and want it totally removed (which will break the text layout) or replaced by something else. Can you confirm this?

Ciao, Mike
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 10

Expert Comment

by:Lischke
Comment Utility
Oh, while I wrote my comment you changed the question's text. But unfortunately it still makes no sense. What exactly does the wide string contain? Is it just a new line (NL = Char(13)) or a NL/LF combination or what else?

Ciao, Mike
0
 

Author Comment

by:kiru
Comment Utility
Edited text of question.
0
 

Author Comment

by:kiru
Comment Utility
I found a solution as TheNeil has put it. I searched for #13 & #10 & removed them from the string(not in widestring, normal string). It is working fine.
 Lischike ,in widestring it shows some
charecter similar to capital I.


0
 
LVL 5

Expert Comment

by:TheNeil
Comment Utility
Thanks Kiru. Your 'capital I' problem might be something that the character set can't display. What you could do is change my example to do this:

  IF TempStr[n] IN ['A'..'Z', 'a'..'z', '0'..'9', ',']
  THEN
    NormalStr := NormalStr + TempStr[n];

You'll need to extend the set to cover all of the characters that you want to actually allow but it will filter out anything that you don't want (or expect)

The Neil =:)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now