This is a discussion on Convert all characters to ISO-8859-1? within the PHP Language forums, part of the PHP Programming Forums category; I have a script that posts text to the USENET. Occasionally, when someone cuts and pastes text into the form ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I have a script that posts text to the USENET. Occasionally, when someone
cuts and pastes text into the form field, they cut and paste a character that isn't part of charset ISO-8859-1, such as a curly looking single quote, etc. I did some searching, but couldn't find and php function that would filter this? Is there anything anyone has written, something like: $string = convert_charset($string,ISO-8859-1); ? If not, what else could I do to do this? (Yes I realize some of the problems involved.) -- [ Sugapablo ] [ http://www.sugapablo.com <--music ] [ http://www.sugapablo.net <--personal ] [ sugapablo@12jabber.com <--jabber IM ] |
|
|||
|
Sugapablo wrote:
> I have a script that posts text to the USENET. Occasionally, when someone > cuts and pastes text into the form field, they cut and paste a character > that isn't part of charset ISO-8859-1, such as a curly looking single > quote, etc. http://www.php.net/iconv does encoding conversions, but chances are that's not quite what you're looking for. I've found that certain characters break form-submissions from Internet Explorer (certain fields in the form are lost - don't ask me why) - ironically enough it only affects IE, and the reason the characters are a problem is because they're put in by Microsoft Word's autocorrect - so I've made a function that removes all these characters. The characters are ascii 150 (the long hyphen), 148 (smart-quote), 146 (single smart-quote) and 133 (tripple dots). So I just do this: str_replace(chr(150), "-", str_replace(chr(148), '"', str_replace(chr(146), "'", str_replace(chr(133), "...", $text)))); And an equivalent client-side version called by onsubmit on the form, and no more problem :) Roy W. Andersen -- ra at broadpark dot no / http://roy.netgoth.org/ "Hey! What kind of party is this? There's no booze and only one hooker!" - Bender, Futurama |
|
|||
|
Sugapablo wrote:
> I have a script that posts text to the USENET. Occasionally, when someone > cuts and pastes text into the form field, they cut and paste a character > that isn't part of charset ISO-8859-1, such as a curly looking single > quote, etc. Isn't actually get converted to html entities when the form is get posted? Or is that a problem for you? > I did some searching, but couldn't find and php function that would filter > this? Is there anything anyone has written, something like: > > $string = convert_charset($string,ISO-8859-1); Not sure <http://in.php.net/utf8_decode> -- <?php echo 'Just another PHP saint'; ?> Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/ |