Link to home
Start Free TrialLog in
Avatar of MaritimeSource
MaritimeSource

asked on

processing line breaks: html text area to database to xml: ^M

Hi,

I have an adhoc cms system, where the user types in content into a text area. Then I save it to a mysql db. Then I have a script which pulls from the DB and inserts into an xml file using php DOM XML functions (php 4). The problem is, in the xml file the line breaks are coming out like so:

^M

I should convert these when I pull it from the database, but before I write it to the xml. THe question is, what character code is this and what character code do I replace it with?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of SStory
SStory
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MaritimeSource
MaritimeSource

ASKER

I want to keep the line break, but I don't want it to show up as ^M in the xml output file. I think this is happening because the web app is used on a windows machine, but the xml is created on a linux server. So I think I should strip the ASCII char 10 and leave the 13 in there? I want to kee the line break, but don't want to convert it to <br> for other reasons. I think the 10 is the one windows introduces.

Why would microsoft ever do such a thing anyway??? DOH
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You are correct.  Unix only uses one of the chars, but Microsoft uses two chars.
Well Carriage return is to go back to the start (left side) horizontally and linefeed to go to the next line.  I guess this carried over from something in computer history.

I would try getting rid of the 10 and see if it works. I assume you are displaying this on a Unix/linux machine and that is why it is a problem.

The <BR> in HTML is platform independent, but I understand why you don't want to fool with it.