in reply to ASCII to HTML

Don't forget the classic

$ascii = "<PRE>$ascii</PRE>";

While not technically HTML, it will probably emulate your textarea (including tabs!) better than any regex will. :)

Replies are listed 'Best First'.
RE: Re: ASCII to HTML
by httptech (Chaplain) on Apr 05, 2000 at 03:28 UTC
    You just need to be careful on this one how you set up the textarea... if the textarea wraps the text automatically the browser doesn't necessarily insert linebreaks for you.
    So your users may type in an entire story with absolutely no linebreaks, and the <pre> tags will force it all on one line. In this case it's best to turn wrapping off in the textarea, so the output will be a faithful reproduction of what the user typed.

      Excellent point. I have a script that uses PRE tags and TEXTAREA input, and I have to manually wrap the long lines using some code that makes a good guess at where to insert a break if the line is too long. Why some people don't hit the 'Enter' key once in a while* is beyond me! Just goes to show you always have to check for all possible cases when dealing with user input.

      I've gotten people who put over 1000 characters on one line. Sheesh!

RE: Re: ASCII to HTML
by little_mistress (Monk) on Apr 05, 2000 at 02:53 UTC
    Good Point!