By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,998 Members | 2,871 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,998 IT Pros & Developers. It's quick & easy.

Convert all characters to ISO-8859-1?

P: n/a
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 ]
[ su*******@12jabber.com <--jabber IM ]

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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
Jul 17 '05 #2

P: n/a
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/

Jul 17 '05 #3

P: n/a
Nope. In the Microsoft universe ISO-8859-1 = CP1252, so curly quotes
don't get escaped.

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.