Convert all characters to ISO-8859-1?

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-12-2005
Sugapablo
 
Posts: n/a
Default Convert all characters to ISO-8859-1?

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 ]

Reply With Quote
  #2 (permalink)  
Old 01-12-2005
Roy W. Andersen
 
Posts: n/a
Default Re: Convert all characters to ISO-8859-1?

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
Reply With Quote
  #3 (permalink)  
Old 01-12-2005
R. Rajesh Jeba Anbiah
 
Posts: n/a
Default Re: Convert all characters to ISO-8859-1?

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/

Reply With Quote
  #4 (permalink)  
Old 01-12-2005
chernyshevsky@hotmail.com
 
Posts: n/a
Default Re: Convert all characters to ISO-8859-1?

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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 10:14 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0