Re: control-M

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Joe, not sure you "str_replace" will work.  I think I need a way to
represent the ^M with an ASCII code.  The ^M character is a single
character.  If you type ^M that is 2 characters, caret + M.  They are
not equal ASCII-wise.

Dave


On Thu, 2005-05-05 at 03:11 -0400, Joe Wollard wrote:
> David,
> 
> Well, I've never seen this issue on a form submission before, but I
> have seen it (and other oddities) when editing text files in vi that
> we created on M$.  You might try something simple first such as:
> <?php
> $text = str_replace("^M\n\r", "\n\r", $_POST['textarea_name']);
> ?>
> 
> I haven't tested that but I'd give that a shot. If you're always
> getting the ^M before a line break this should work but I haven't
> tested it to be sure. Even if you have to modify it I would still use
> str_replace instead of a regular expression since you'll know exactly
> what/ where the string is that you want to get rid of.
> 
> If ^M isn't actually being detected as a literal string you would just
> replace it with the ASCii value inside of the chr() function.....I
> think ;-)
> 
> Cheers!
> -Joe
> www.joewollard.com
> 
> 
> David Christensen wrote: 
> > I know I'm missing something, but I can't seem to find it or figure it
> > out.  I've done the google search, and I've done a quick scan of the
> > list archives, but I can't seem to find the right way to remove
> > control-M from a form submission page with textarea fields.
> > 
> > I have a series of "textarea" fields that can/and do contain the dreaded
> > ^M characters.  For the life of me, I can't figure out how to remove
> > them before I save them to the database, and how to remove the ones that
> > are all ready stored there when I query them back to the browser from a
> > web page.  Also, if I do remove them, how do I make sure I format the
> > text correctly when I push it back to the browser as the default values
> > of these fields?
> > 
> > Point me to the elixir of knowledge and let me bath in the fortitude of
> > a master regex expression to rid me once and for all of the dreaded
> > ^M!!!
> > 
> > Thank you, and good night!
> > 
> > "That's why I won't do 2 shows!  I won't do it!"
> > 
> >   

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux