Re: [PHP] Removing ^M

2002-06-09 Thread Michael Hall


As a result of my original request, I now have half a dozen ways of doing
this using php, perl, python and tr :)

I guess this is sort of on topic because there may be PHP
programmers who want to do this without writing a PHP script that
probably has to be run by a web server.

Anyway, someone on the Python list suggested this variety of tr:

tr -d '\015' infile outfile

I haven't tested this. 015 is the numeric code for \r.

Mick


On Sat, 8 Jun 2002, Steve Buehler wrote:

 I get this when running that command:
 tr: only one string may be given when deleting without squeezing repeats
 
 
 I looked at the tr man pages and it didn't help much.  I also tried using 
 '\r' and `\r` and just \r , but always get the same result.
 
 Steve
 
 At 11:07 PM 6/8/2002 +0200, you wrote:
 why not just run
  tr -d \r htmlfile.htm
 
 
 - Original Message -
 From: Michael Hall [EMAIL PROTECTED]
 To: PHP List [EMAIL PROTECTED]
 Sent: Sunday, June 09, 2002 2:40 AM
 Subject: [PHP] Removing ^M
 
 
  
  
   I am trying remove ^M characters (some kind of newline character) from an
   HTML file. I've tried all sorts of ereg_replace and sed possibilities
   but the
   things just won't go away. Does anyone have a way of removing such
   characters?
  
   TIA
  
   Mick
  
  
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 --
 This message has been scanned for viruses and
 dangerous content by MailScanner, and is
 believed to be clean.
 ow3
 
 
 
 

-- 

n   i   n   t   i  .   c   o   m
php-python-perl-mysql-postgresql

Michael Hall [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Removing ^M

2002-06-08 Thread Michael Hall



I am trying remove ^M characters (some kind of newline character) from an
HTML file. I've tried all sorts of ereg_replace and sed possibilities
but the
things just won't go away. Does anyone have a way of removing such
characters?

TIA 

Mick




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Removing ^M

2002-06-08 Thread Sqlcoders.com Programming Dept

You could replace if by ASCII code (^M is actually a representation of ASCII
013, the CR character, thanks to
http://www.mindspring.com/~jc1/serial/Resources/ASCII.html for the ASCII
lookup table.).

This should fix it (untested)

?

$chrnumber = 13; //this is the ascii code for ^M

$nicestring = str_replace(chr($chrnumber),(removed M was
here),$badstring);

echo($nicestring);

?

where $nicestring is the output,
$chrnumber contains the ascii code for ^M,
and the input (original) string is $badstring.




Sqlcoders.com Dynamic data driven web solutions
- Original Message -
From: Michael Hall [EMAIL PROTECTED]
To: PHP List [EMAIL PROTECTED]
Sent: June 08 2002 05:40 PM
Subject: [PHP] Removing ^M




 I am trying remove ^M characters (some kind of newline character) from an
 HTML file. I've tried all sorts of ereg_replace and sed possibilities
 but the
 things just won't go away. Does anyone have a way of removing such
 characters?

 TIA

 Mick




 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Removing ^M

2002-06-08 Thread Miguel Cruz

On Sun, 9 Jun 2002, Michael Hall wrote:
 I am trying remove ^M characters (some kind of newline character) from
 an HTML file. I've tried all sorts of ereg_replace and sed possibilities
 but the things just won't go away. Does anyone have a way of removing
 such characters?

  $str = str_replace(\r, '', $str);

miguel


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Removing ^M

2002-06-08 Thread Chris Knipe

Perl apparently also works very nice for this

open (FILE, filename):
open (NEWFILE, filename);

WHILE (FILE) {
  chomp;
  print NEWFILE $_
}

close (FILE);
close(NEWFILE);

this should take care of ^M
Kind Regards,

Chris Knipe
MegaLAN Corporate Networking Services
Tel: +27 21 854 7064
Cell: +27 72 434 7582

- Original Message - 
From: Michael Hall [EMAIL PROTECTED]
To: PHP List [EMAIL PROTECTED]
Sent: Sunday, June 09, 2002 2:40 AM
Subject: [PHP] Removing ^M


 
 
 I am trying remove ^M characters (some kind of newline character) from an
 HTML file. I've tried all sorts of ereg_replace and sed possibilities
 but the
 things just won't go away. Does anyone have a way of removing such
 characters?
 
 TIA 
 
 Mick
 
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Removing ^M

2002-06-08 Thread Miguel Cruz

'chomp' removes the end-of-line character(s) from its input, which is 
different from doing an EOL conversion (which is what the OP was after). 
The result of the below perl would be to concatenate all lines together as 
one.

miguel

On Sat, 8 Jun 2002, Chris Knipe wrote:
 Perl apparently also works very nice for this
 
 open (FILE, filename):
 open (NEWFILE, filename);
 
 WHILE (FILE) {
   chomp;
   print NEWFILE $_
 }
 
 close (FILE);
 close(NEWFILE);
 
 this should take care of ^M
 Kind Regards,
 
 Chris Knipe
 MegaLAN Corporate Networking Services
 Tel: +27 21 854 7064
 Cell: +27 72 434 7582
 
 - Original Message - 
 From: Michael Hall [EMAIL PROTECTED]
 To: PHP List [EMAIL PROTECTED]
 Sent: Sunday, June 09, 2002 2:40 AM
 Subject: [PHP] Removing ^M
 
 
  
  
  I am trying remove ^M characters (some kind of newline character) from an
  HTML file. I've tried all sorts of ereg_replace and sed possibilities
  but the
  things just won't go away. Does anyone have a way of removing such
  characters?
  
  TIA 
  
  Mick
  
  
  
  
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Removing ^M

2002-06-08 Thread Chris Knipe

print NEWFILE $_ . \n;

Then :P

This isn't a perl list, it's off topic.  Just thought it might help if I
added this to the pool Let's rather not go into a in depth discussion
about it... I'm no perl guru either.


Kind Regards,

Chris Knipe
MegaLAN Corporate Networking Services
Tel: +27 21 854 7064
Cell: +27 72 434 7582

- Original Message -
From: Miguel Cruz [EMAIL PROTECTED]
To: Chris Knipe [EMAIL PROTECTED]
Cc: PHP List [EMAIL PROTECTED]
Sent: Saturday, June 08, 2002 7:51 PM
Subject: Re: [PHP] Removing ^M


 'chomp' removes the end-of-line character(s) from its input, which is
 different from doing an EOL conversion (which is what the OP was after).
 The result of the below perl would be to concatenate all lines together as
 one.

 miguel

 On Sat, 8 Jun 2002, Chris Knipe wrote:
  Perl apparently also works very nice for this
 
  open (FILE, filename):
  open (NEWFILE, filename);
 
  WHILE (FILE) {
chomp;
print NEWFILE $_
  }
 
  close (FILE);
  close(NEWFILE);
 
  this should take care of ^M
  Kind Regards,
 
  Chris Knipe
  MegaLAN Corporate Networking Services
  Tel: +27 21 854 7064
  Cell: +27 72 434 7582
 
  - Original Message -
  From: Michael Hall [EMAIL PROTECTED]
  To: PHP List [EMAIL PROTECTED]
  Sent: Sunday, June 09, 2002 2:40 AM
  Subject: [PHP] Removing ^M
 
 
  
  
   I am trying remove ^M characters (some kind of newline character) from
an
   HTML file. I've tried all sorts of ereg_replace and sed possibilities
   but the
   things just won't go away. Does anyone have a way of removing such
   characters?
  
   TIA
  
   Mick
  
  
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
 
 


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Removing ^M

2002-06-08 Thread Dave Raven

why not just run
tr -d \r htmlfile.htm


- Original Message - 
From: Michael Hall [EMAIL PROTECTED]
To: PHP List [EMAIL PROTECTED]
Sent: Sunday, June 09, 2002 2:40 AM
Subject: [PHP] Removing ^M


 
 
 I am trying remove ^M characters (some kind of newline character) from an
 HTML file. I've tried all sorts of ereg_replace and sed possibilities
 but the
 things just won't go away. Does anyone have a way of removing such
 characters?
 
 TIA 
 
 Mick
 
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Removing ^M

2002-06-08 Thread Steve Buehler

I get this when running that command:
tr: only one string may be given when deleting without squeezing repeats


I looked at the tr man pages and it didn't help much.  I also tried using 
'\r' and `\r` and just \r , but always get the same result.

Steve

At 11:07 PM 6/8/2002 +0200, you wrote:
why not just run
 tr -d \r htmlfile.htm


- Original Message -
From: Michael Hall [EMAIL PROTECTED]
To: PHP List [EMAIL PROTECTED]
Sent: Sunday, June 09, 2002 2:40 AM
Subject: [PHP] Removing ^M


 
 
  I am trying remove ^M characters (some kind of newline character) from an
  HTML file. I've tried all sorts of ereg_replace and sed possibilities
  but the
  things just won't go away. Does anyone have a way of removing such
  characters?
 
  TIA
 
  Mick
 
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
ow3



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Removing ^M

2002-06-08 Thread Miguel Cruz

I don't think tr expects to receive a filename on the command line. Try:

   tr -d \r  oldfile.html  newfile.html

miguel

On Sat, 8 Jun 2002, Steve Buehler wrote:
 I get this when running that command:
 tr: only one string may be given when deleting without squeezing repeats
 
 
 I looked at the tr man pages and it didn't help much.  I also tried using 
 '\r' and `\r` and just \r , but always get the same result.
 
 Steve
 
 At 11:07 PM 6/8/2002 +0200, you wrote:
 why not just run
  tr -d \r htmlfile.htm
 
 
 - Original Message -
 From: Michael Hall [EMAIL PROTECTED]
 To: PHP List [EMAIL PROTECTED]
 Sent: Sunday, June 09, 2002 2:40 AM
 Subject: [PHP] Removing ^M
 
 
  
  
   I am trying remove ^M characters (some kind of newline character) from an
   HTML file. I've tried all sorts of ereg_replace and sed possibilities
   but the
   things just won't go away. Does anyone have a way of removing such
   characters?
  
   TIA
  
   Mick
  
  
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 --
 This message has been scanned for viruses and
 dangerous content by MailScanner, and is
 believed to be clean.
 ow3
 
 
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php