Convert all characters to ISO-8859-1?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sugapablo

    #1

    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@12jab ber.com <--jabber IM ]

  • Roy W. Andersen

    #2
    Re: Convert all characters to ISO-8859-1?

    Sugapablo wrote:[color=blue]
    > 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.[/color]

    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

    Comment

    • R. Rajesh Jeba Anbiah

      #3
      Re: Convert all characters to ISO-8859-1?

      Sugapablo wrote:[color=blue]
      > I have a script that posts text to the USENET. Occasionally, when[/color]
      someone[color=blue]
      > cuts and pastes text into the form field, they cut and paste a[/color]
      character[color=blue]
      > that isn't part of charset ISO-8859-1, such as a curly looking single
      > quote, etc.[/color]

      Isn't actually get converted to html entities when the form is get
      posted? Or is that a problem for you?
      [color=blue]
      > I did some searching, but couldn't find and php function that would[/color]
      filter[color=blue]
      > this? Is there anything anyone has written, something like:
      >
      > $string = convert_charset ($string,ISO-8859-1);[/color]

      Not sure <http://in.php.net/utf8_decode>


      --
      <?php echo 'Just another PHP saint'; ?>
      Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

      Comment

      • chernyshevsky@hotmail.com

        #4
        Re: Convert all characters to ISO-8859-1?

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

        Comment

        Working...