note 13373 modified in ref.strings by maxim

From: Date: Tue, 12 Nov 2002 16:21:00 +0000
Subject: note 13373 modified in ref.strings by maxim
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-39398@lists.php.net to get a copy of this message
Browsers (Internet Explorer at least) won't wrap text immediately before puntuation . ? ! ( ) [ ] { } / even if the preceeding character is whitespace. I believe this is intentional widow/orphan prevention behavior. This complicates the processing of user-inputed text (e.g. the message board junk problem). Even if you use <textarea wrap=hard> to force newlines into the input text (which is imperfect since a clever user can just modify the HTML before posting), people posting long strings of punctuation characters, or just punctuation characters at the beginning of each line in the <textarea> will mess up the format of the page for users viewing their post. You obviously can't solve this by just inserting a spaces - the browser still won't wrap. My solution is to use str_replace to put a &nbsp; (the least visually impacting non-whitespace character I can think of) between the \n and any pucntuation so the wrap can happen in the whitespace before the &nbsp;. Kindof ironic to be using &nbsp; to *cause* a break:) [Editor's note: You could also use wordwrap() function Maxim Maletsky] --was-- Browsers (Internet Explorer at least) won't wrap text immediately before puntuation . ? ! ( ) [ ] { } / even if the preceeding character is whitespace. I believe this is intentional widow/orphan prevention behavior. This complicates the processing of user-inputed text (e.g. the message board junk problem). Even if you use <textarea wrap=hard> to force newlines into the input text (which is imperfect since a clever user can just modify the HTML before posting), people posting long strings of punctuation characters, or just punctuation characters at the beginning of each line in the <textarea> will mess up the format of the page for users viewing their post. You obviously can't solve this by just inserting a spaces - the browser still won't wrap. My solution is to use str_replace to put a &nbsp; (the least visually impacting non-whitespace character I can think of) between the \n and any pucntuation so the wrap can happen in the whitespace before the &nbsp;. Kindof ironic to be using &nbsp; to *cause* a break:) http://www.php.net/manual/en/ref.strings.php

« previous php.notes (#39398) next »