Skip to main content.
home | support | download

Back to List Archive

Re: Using prog, how do I seperate files?

From: Bill Moseley <moseley(at)>
Date: Sat Mar 29 2003 - 07:45:07 GMT
On Fri, 28 Mar 2003, Eric Estabrooks wrote:

> I solved my problem. It was all related to the \r\n problem.
> This is what I did:
> I was attempting to index an XML document that was stored in a mySQL
> database. Paying attention to the hints provided by Bill Moseley, replaced
> all the "\r\n" in my document with "\n".

I don't have a windows machine to test with, but in perl (like C) strings
are terminated with \n.  In Windows when you print to a file (in text
mode) that \n gets written as \r\n to have DOS line endings.  When \r\n
strings are read into perl (or C) in text mode \r\n is converted to \n.

So strlen() returns the length of the string without the \r.  In
otherwords, strlen("abcd\n") is five but when it's written to disk it's
six bytes (unles writing in binary mode).

What all that means is regardless of platform reading in a string it ends
up the same length.  But in your case with PHP it would seem that the
length of the string depends on what platform you are using.  That seems

It would seem then that the string length that PHP is returning is
including the \r character.  That would cause the problems you have
described with swish since the string length is wrong.


> In PHP:
> 	$theDocFixed = preg_replace( "/\\r\\n/", "\n", $theDoc);

That's the syntax?  Yikes.  \\n looks more like a backslash followed by a
letter "n".

Bill Moseley
Received on Sat Mar 29 07:48:49 2003