Subject: Re: '^M' in ascii files
To: Jeff Rizzo <riz@boogers.sf.ca.us>
From: Randy Arabie <rrarabie@arabie.org>
List: netbsd-help
Date: 02/09/2002 11:28:17
On Sat, 9 Feb 2002, Jeff Rizzo wrote:

> On Sat, Feb 09, 2002 at 11:13:17AM -0700, Randy Arabie wrote:
> > Maybe this isn't a NetBSD thing....
> > 
> > I've got a gzipped tarball of files, all ascii stuff - *.php 
> > and *.html.
> > 
> > When I 'tar xvfz' the files onto my linux box I have no problems.
> > 
> > However, when I 'tar xvfz' them onto my NetBSD box, many of the 
> > files have '^M' appended to the end of each line.  The PHP engine 
> > doesn't seem to like this.
> 
> These files must be from DOS/Windows.  UNIX-like OSes use LF as the newline
> char; DOS uses CRLF.  (The CR is what you're seeing as ^M)
> 
> Probably linux is hiding this information from you... I'm sure the
> characters are there.   Your simplest bet is to compile the "unix2dos"
> package from pkgsrc;  (pkgsrc/converters/unix2dos) it has a simple-to-use
> newline converter that goes both ways.

I'll give it a whirl. Thanks ;-)

> > I thought it was a problem with the tarfile, but apparently it 
> > isn't, since the carriage returns are not present in the files 
> > on my linux box.
> > 
> > Is there some flag I need to pass tar to prevent this?
> > 
> > I know I can use strings, or some perl commands to clean these 
> > files up, but it would be nicer to prevent it outright.
> 
> I'll admit to being somewhat surprised that PHP doesn't ignore the
> extra CR, but no flag to tar (that I know of, anyway) will do the
> conversion for you.

Well, that was my assumption...perhaps there are other, greater problems 
which these files.

-- 

Cheers!

Randy