Carriage Return/Line Feed Problem

Hi guys,

I wrote some code that gets the HTML from a Web page and stores it in a
buffer, then I display the buffer in a big multiline CEdit box. The problem
is that on many pages I don't get new lines, I just get a thick solid
verticle line kinda like this: || where it should return.

Also, if I view the pages (view source) in Notepad they look fine.

Most pages do that, but interestingly Microsoft pages do the proper new line
and look great in my edit box.

Maybe I have to replace all the \r with \r\n or something like that ? Does a
\r\n still only take up 1 char ? I download the page in a BYTE buffer, I
tried a cast to (char*)pBuffer with no success. Any ideas ? Thanks.


Here is a sample:

<html> (FAT LINE HERE) <head> (FAT LINE HERE) <meta NAME=...>

(I just copied and pasted directly from my CEdit and the returns worked here
so I added the FAT LINE text)


0
4/7/2004 3:51:41 AM
vc.mfc 33608 articles. 0 followers. Follow

6 Replies
656 Views

Similar Articles

[PageSpeed] 57

On Windows \r\n sequence designates end of the line
so you need to insert it in order to have lines in the multiline CEdit.
Make sure to set correct styles in the multiline CEdit.

"Robert A." <invalid@invalid.org> �������/�������� � �������� ���������:
news:OK6okOFHEHA.3576@tk2msftngp13.phx.gbl...
> Hi guys,
>
> I wrote some code that gets the HTML from a Web page and stores it in a
> buffer, then I display the buffer in a big multiline CEdit box. The
problem
> is that on many pages I don't get new lines, I just get a thick solid
> verticle line kinda like this: || where it should return.
>
> Also, if I view the pages (view source) in Notepad they look fine.
>
> Most pages do that, but interestingly Microsoft pages do the proper new
line
> and look great in my edit box.
>
> Maybe I have to replace all the \r with \r\n or something like that ? Does
a
> \r\n still only take up 1 char ? I download the page in a BYTE buffer, I
> tried a cast to (char*)pBuffer with no success. Any ideas ? Thanks.
>
>
> Here is a sample:
>
> <html> (FAT LINE HERE) <head> (FAT LINE HERE) <meta NAME=...>
>
> (I just copied and pasted directly from my CEdit and the returns worked
here
> so I added the FAT LINE text)
>
>


0
dimazhn (16)
4/7/2004 5:50:43 AM
I still don't understand because when I copy from my edit box and paste
somewhere else (say, in this message) it comes out fine so the \r\n must be
there, it also displays fine in Notepad. It just comes out wrong in my edit
box; and Microsoft code (from a MS web site) comes out fine in my edit box.


0
4/7/2004 5:26:25 PM
"Robert A." <invalid@invalid.org> wrote in message
news:OAE50VMHEHA.2576@TK2MSFTNGP09.phx.gbl...
> I still don't understand because when I copy from my edit box and paste
> somewhere else (say, in this message) it comes out fine so the \r\n must
be
> there, it also displays fine in Notepad. It just comes out wrong in my
edit
> box; and Microsoft code (from a MS web site) comes out fine in my edit
box.
>
>

Don't let the fact that some pages work and others don't worry you. That's
entirely up to the platform that they were written on. e.g. A web page
written on a Windows machine will have the "/r/n" (which are two bytes),
whereas a page written on an unix system will have just "/n". Let's deal
with your points one by one.

1.    When you copy from your edit box, I assume that the text got there by
your typing. When you pressed the "return" key, a /r/n was inserted, because
you are using a Windows machine.
2.    When you do a "View Source", IE fixes up the line feeds for you.
3.    Microsoft pages were developed on Windows machines.

So, the solution is, that you have to check the format of the code, and fix
it if necessary.

Jase


0
jshelley (197)
4/8/2004 1:28:38 AM
Thanks Jase, that's kind of what I figured.

So then a /r/n is actually 2 bytes ? That means if I want to fix it up
manually I have to reallocate my buffer with an extra X bytes where X is the
number of /r/n items, that seems like a big pain. I also have to see if a /r
is directly followed by a /n to get the page type, that's not that big of a
deal. Too bad I couldn't just do a character replace.

So when you View Source IE must do what I described above ?

What if I use WCHARs ?

I'm writing a program where you enter a URL and automatically get the HTML
source in a an edit box so what's in the edit box is usually *not* typed in
by the user.

Any ideas ? Thanks.


0
4/8/2004 5:32:50 AM
"Robert A." <invalid@invalid.org> wrote in message
news:%23WvMxrSHEHA.2012@TK2MSFTNGP09.phx.gbl...
> Thanks Jase, that's kind of what I figured.
>
> So then a /r/n is actually 2 bytes ? That means if I want to fix it up
> manually I have to reallocate my buffer with an extra X bytes where X is
the
> number of /r/n items, that seems like a big pain. I also have to see if a
/r
> is directly followed by a /n to get the page type, that's not that big of
a
> deal. Too bad I couldn't just do a character replace.
>
> So when you View Source IE must do what I described above ?
>
> What if I use WCHARs ?
>
> I'm writing a program where you enter a URL and automatically get the HTML
> source in a an edit box so what's in the edit box is usually *not* typed
in
> by the user.
>
> Any ideas ? Thanks.
>

Well... you've got it all right there. You don't have to worry about
increasing storage if you copy everything to a CString object char by char,
inserting \r when necessary. BTW I believe that the unix line feed is a \n,
but you'd better check.

Can't help with WCHARs.

Jase


0
jshelley (197)
4/8/2004 7:24:46 AM

CString s = _T("This\nis\na'nmultiline\nexample");

s.Replace(_T("\n"), _T("\r\n"));

Note that there is no need for you to reallocate; it is handled magically by the Replace
operator. If you want to normalize it, you first do

s.Replace(_T("\r\n"), _T("\n"));

so if there were any CRLFs they get removed, then you put them back. 

If you care, you might consider 
if(s.Find(_T("\r\n")) >= 0)
   { /* already in CRLF format */
   } /* already in CRLF format */
else
  { /* put into CRLF format */
  } /* put into CRLF format */

This is naive code in that it assumes that if a CRLF appears anywhere then all instances
of LF will have a CR in front. This may or may not be a safe assumption. You could
obviously write a more complex loop, but the normalize-and-replace is going to be about as
fast, and takes only two lines of code to write.

Note your observation about cutting and pasting meaning that somehow it is "right" is
irrelevant; good programs understand that they have to do the substitution and handle it,
transparently for you. It is an unfortunately histroical artifact that edit controls don't
understand LF==CRLF, but it is far too late to change it (a bare CR has a different
meaning in an edit control)

Give we are talking about Web pages here (a few bytes at most; (usually less than 20K) I
wouldn't worry about performance issues for anything up to a quarter-megabyte, and even
then I'd probably not take it seriously), I see no perforamnce problems.
				joe

On Thu, 8 Apr 2004 01:32:50 -0400, "Robert A." <invalid@invalid.org> wrote:

>Thanks Jase, that's kind of what I figured.
>
>So then a /r/n is actually 2 bytes ? That means if I want to fix it up
>manually I have to reallocate my buffer with an extra X bytes where X is the
>number of /r/n items, that seems like a big pain. I also have to see if a /r
>is directly followed by a /n to get the page type, that's not that big of a
>deal. Too bad I couldn't just do a character replace.
>
>So when you View Source IE must do what I described above ?
>
>What if I use WCHARs ?
>
>I'm writing a program where you enter a URL and automatically get the HTML
>source in a an edit box so what's in the edit box is usually *not* typed in
>by the user.
>
>Any ideas ? Thanks.
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15975)
4/10/2004 6:37:23 PM
Reply:

Similar Artilces:

Problems with rules
I have a problem with a rule. When I get email from a certain address it ends up in my designated spam folder. The problem is that this particular email address is not listed in my unwanted email list and no rules are supposed to trigger on the message in question. What could be causing this? ...

can't fix Money stopped working problem
I was able to access and use it completely a couple of days ago and I suddenly started getting messages that it wasn't working. I tried uninstalling and reinstalling from the CD, but still can't get past the log in page. I tried logging in and skipping the internet access, but still no success. There are no recent changes to my computer that I see. found a "fix" on the support site for money plus when it suddenly stops working. I can't update the program now because I can't get in. When I tried to change the DEP settings to except the files listed in the ...

Problem with objItem.InvokeVerbEx("Print")
Hi, I have found several examples of scripts that use this: "objItem.InvokeVerbEx("Print")" to print text files. However, when I use it, I get a dialog box for every single file printed with the date/time and an OK button. This is really anoying if you have hundreds of files to Print. I have seen the issue brought up before, but no answer to the question. I did try to send it to NUL objItem.InvokeVerbEx("Print") > NULL but that did nothing at all. Is there a way to print all the text files in a directory with out having to click OK 100 ti...

Outlook Problem #28
This is a multi-part message in MIME format. ------=_NextPart_000_08C5_01C45F62.7BD33710 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I have a user who when closes Outlook and opens it again, it says that = the Exchange server is no longer available. I setup the Outlook to = point to the Exchange again and it works fine. But when you close it, = it does it again. Any ideas! --=20 Maurice ------=_NextPart_000_08C5_01C45F62.7BD33710 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable ...

Problems with autosum...
I'm using Excel to carry out simple accountancy tasks. I'm using autosum to total up a column of figures to two decimal places. In some worksheets it works fine, in others the resulting autosum value is 0.02 less than the actual sum of the column. Has anyone else experienced this problem or does anyone know a solution? This is a rounding effect. I expect you have formatted the numbers to show two decimal places. For example: in cells A10 and A11 you might see 12.34 and 10.54 but the actual (stored) values are 12.33612 and 10.53592. These add to 22.87204 which is displayed as 22...

Word as EMail Editor in Outlook, Smartquote Problem
Using Office 2003 in Win XP Pro. Word is set as e-mail editor in Outlook. Word is set to use smartquotes, as they look better than the plain straight quotes, in Word documents. However, that seems to cause problems in Outlook e-mail. Spell-checker reports that words are spelled incorrectly, and if sent as is, the other party receives them seeing squares instead of quotation marks. How can I fix this? Has anyone come up with a solution? You have to pick a font that you know has the characters, since not everyone receiving it is guaranteed to have the same font story that you have.... --...

Re: Tax Line Manager shows incorrect salary and tax projections
Hi I have exactly the same problem. Did anybody find a solution? Thanks, V. JC wrote: > *Hi - > > The Tax Line Manager shows the correct Year to Date Salary amoun > but > for some reason, the Projected Total for 2004 is way off. When > drill > down to the projection details, it includes my projected quarterly > bonus but not the regular salary (taxable income) amounts for th > rest > of the year. Same issue with the W-2 tax categories - the projection > includes the taxes for the quarterly bonus but not the regula > salary. > I am using Money 2003, wo...

Carriage Return/Newline in CEdit ?
Hi guys, I want my user to be able to "\r\n" into a CEdit to specify he wants a carriage return, but when he enters it it becomes a string literal (is that the right term ?) For example, the user wants these created strings to end with a \r\n : CString left="some stuff"; m_edit.GetWindowText(right); The user types "\r\n" in the edit box to cause a line break. CString output=left+right; // should end with "\r\n" That's a simplified example but I think I explained it right. Take care, Robert Hi Robert, I'm not sure what you want exactl...

Line Series Color on Graph
Is there a way to make a line series on a line graph change colors based on the value of another line? I have a line graph that has 2 lines. 1 green line representing Total Expenses and 1 line representing Total Revenue. I would like the line representing Total Revenue to be red whenever it is below the line representing Total Expenses and then change to blue whenever it goes above the Total Expenses line. Is this possible? Check out Jon's page on conditional chart formatting: http://peltiertech.com/Excel/Charts/format.html#CondChart -- Best Regards, Luke M *Remem...

2 Y Axes: Lines and a Stacked Column
Hello, I'm using Excel 2003 SP3 and having trouble with the following... Sample data: X Axis Y Axis1 Y Axis1 Y Axis2 Y Axis2 Y Axis2 Date DataA DataB DataC DataD DataE 1/31/09 4.3 3.6 10% 40% 50% 2/28/09 2.9 1.9 30% 60% 10% 3/31/09 1.2 6.4 15% 10% 75% I need Y Axis1 to be two simple lines and Y Axis2 a stacked column that sums to 100%. Can't figure this out. Please advise... Thanks! Jeff First, clear the cell above the dates,...

how do I remove the separator line after deleting a footnote in w.
how do I remove the separator line at the bottom of a page after deleting a footnote in word 2007 Provided you deleted the footnote correctly (by deleting the reference mark in the document body), the separator should not still be there. The fact that it is suggests that there is some residue of the footnote remaining. At a minimum, display nonprinting characters so you can see what you're dealing with. You may need to search the document for ^f (footnote reference mark) to find where the elusive footnote is hiding. -- Suzanne S. Barnhill Microsoft MVP (Word) Words int...

Problems when Ripping CDs to .mp3
I've started ripping a lot of my CDs to .mp3 format, but keep running into a problem when doing so. I'm currently using Windows XP & Windows Media Player 11. When I insert a CD, the ripping process begins as it should. A folder is created with the Artist name, Album name, Song titles, etc. Somewhere along the way, though, the Media Player and/or OS begins to "redo" things and creates a folder titled "Unknown Artist" along with a bunch of subfolders titled "Unknown Album (5-29-2010 1-46-31 PM). The subfolders all contain certain tracks f...

Strange problem after migration
After migrating over to Server 2003 and Exchange 2003 we are having a strange user poblem with Exchange. I migrated the user accounts over with the ADM tool then installed/migrated exchange over from 5.5. Now when I try to connect to OWA or using Outlook I have to login as: HCS\jhay instead of just jhay. HCS was the old NT4 domain and now my new domain is trillion21. I did the steps listed in Microsoft's Exchange 2003 Deployment Guide and everything went fine with no errors. Another thing is that if I go into AD Users and right click on a user it does not have any Exchange taks e...

Re: Public Folders permissions problem
ooops ... we're on Exchange 2003. j -- jj runnion jjrNOSPAM@sinte.edu "JJ Runnion" <jjrNOSPAM@sinte.edu> wrote in message news:... > somehow we've gotten "locked out" of permissions on the calendars and > other folders in our Public Folders. > When I right-click on the calendar in Exchange Manager Admin > Group\Folders\Public Folders, a username/password box pops up and won't > take any of the admin username/passwords (domain admin, enterprise admin, > etc.). I get "the operation failed. ID no:80007005 Exchange system > M...

Contact selection problem in CRM 4 Mail Merge
I can use mail merge option for all contacts on page (grid) without any problems, but if I select one contact or a small selection of contacts the merge resulting list has one entry but only data from the user entity, not from the contact entity...I have no contacts to merge. Merge also fails if I select a merge from an open contact form. I have selected contact attributes in the template. I have administrative rights. Any ideas? ...

Pub 2007: fill and line colours only show up as black and white
I've used Publisher for years and have never encountered this problem until today. I'm running Publisher 2007 on Windows XP (Service Pak 2) with a Canon PIXMA iP4000. The print set up is for colour (not greyscale). I can change the colour of text, and the jpeg images I've imported display in full colour but suddenly, my current document will not display any line colours or fill colours except black, white or NONE, regardless of what other colours I select. It's as if some hidden default setting has suddenly been turned on. For example, if i create a rectangle and g...

Outlook 2002 Installation Problem #2
I installed my Outlook 2002 when I attempted to start it it refused to start giving me this message: "unable to open your default e-mail folders. The DLL file for the infrmation service could not be found. MAPI was unable to load the information service PSTPRX.DLL. Be sure the service is correctly installed and configured. Do you have any ideas for me Will Decker wdecker2@cox.net Create a new mail profile. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal...

Can my incoming email be returned while on vacation
I am going on vacation. Instead of having to return to overwhelming server downloading of all incoming emails, can I do some thing to automatically reply that I am away from the office? If your isp supports it, you can set up a vacation responder on the mail server. ( If you do it in outlook, you need to leave the computer running while you are on vacation.) This won't help much with the volume of mail you have to deal with when you get back though. -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: h...

Return highest count of one field when duplicate found on another field
I have a table with department IDs, department heads and headcount. Sometimes there are two department heads per department ID. I want to show the head with the largest staff as the leader. I've created a total query to show the count of the staff. Where can I go from there? SELECT [DeptHeadcountTable].DeptID, [DeptHeadcountTable].[Director], Count([DeptHeadcountTable].[EmployeeID]) AS [CountOfEmployeeID] FROM [DeptHeadcountTable] GROUP BY [DeptHeadcountTable].DeptID, [DeptHeadcountTable].[Director]; Try this -- SELECT [DeptHeadcountTable].DeptID, (SELECT TOP 1 [XX].[Department...

problem with losing control of a worksheet
I am completely flabbergasted; I am editing a worksheet which is 1/5th what it used to be - comparing two databases which are somewhat out of control. If two lines match exactly, I delete them, if two lines exist but do not match, I correct the database and delete them, and if there is an orphan, I hide it, with the intent of going back to match them against other databases. Now I am getting a weird display, with different words in column A, am unable to go below line 30, and am coming to the conclusion the worksheet has been compromised. I just printed off a section for further work...

can someone help me with this memorized report problem??
i have modified a sales commission report to include tender information by adding a JOIN to the tenderentry table, here is my TablesQueried section from my report: FROM TransactionEntry WITH(NOLOCK) INNER JOIN [Transaction] WITH(NOLOCK) ON TransactionEntry.TransactionNumber = [Transaction].TransactionNumber LEFT JOIN SalesRep WITH(NOLOCK) ON TransactionEntry.SalesRepID = SalesRep.ID LEFT JOIN Customer WITH (NOLOCK) ON [Transaction].CustomerID = Customer.ID LEFT JOIN Item WITH(NOLOCK) ON TransactionEntry.ItemID = Item.ID LEFT JOIN TenderEntry WITH(NOLOCK) ON TransactionEntry.TransactionNu...

Problem with fonts which switch
Dear users, I have a problem with MS Outlook 2002. Sometimes, the font of my messages suddenly switches from the default font 'courier new' to 'arial', i.e. from an fixed-width font to an proportional font although my default settings are: 1) mail sending format: plain text 2) international font / proportional font: courier new 3) international font / fixed-width font: courier new (Note: I know that 'courier new' is not an propoartional font but my problem also occurs if the proportional font is arial.) How is this possible? Is this due to that in a message there a...

This Message has Extra Line breaks...
I sometimes get an email in Outlook 2003, with "This Message has Extra Line breaks" at the top. If I click on this to restore the line breaks, the formatting is generally much better. It appears that Outlook 2003 is trying to improve the formatting but makes a mess of it. Is there a way to turn this feature off so that I don't have to click to restore the line breaks? Yes, the setting you're after is under Tools > Options > Preferences > Email Options. Uncheck the box labelled Remove extra line breaks in plain text messages. -Peter "Jay" <->...

macro's problem
Firstly, excuse my ignorance in advance to those who make coding in VB look so easy! Hi everyone Can anyone show me how to filter on a column containing dates in the format of 21/04/59 being (21st April 1959), I set about recording a macro that first put a filter on the worksheet, then I selected the column with dates in and go to custom filter then select "equal to or lesser than" and key in the value 30/09/2005, but all that happens when I run this is I get blank lines ... code below Sub less_than() ' ' less_than Macro ' Macro recorded 07/10/2005 by SGUHT ' ...

WebQuery Problem
Hello I often import stock quotes with the webquery feature. Generally I do not have any problems but the following url often generates the error 1004: http://www.swissquote.ch/fcgi-bin/stockfquote?symbols=UKRAI Sometimes I'm able to get the quotes, sometimes not. Does anybody know how I can solve this issue? Regards, Tom ...