Replace extended ascii characters

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?iso-8859-1?B?RnJhbiBHYXJj7WE=?=

    Replace extended ascii characters

    I've some text with some extended ascii characters like ¿ or ¡ and I
    wanna replace these characters for blanks, but when I use the function
    str_replace, it returns an invalid string, so I think that php cannot
    detect these kind of characters and of course, it cannot replace them.

    I've already tried to use mb_ereg_replace , but it doesn´t work. Has
    anybody any idea how can I get a solution for this problem?

    Thanks in advance!

  • Jeff

    #2
    Re: Replace extended ascii characters

    Have you tried using the str_replace with the chr function. Something
    like: str_replace(chr (168), ' ', $str);

    There is also a function that a user submitted on this PHP manual page
    that replaces all non-readable characters with a '.', you could change
    it to make it a blank and it might work exactly for your needs.

    Generate a single-byte string from a number


    Comment

    • =?iso-8859-1?B?RnJhbiBHYXJj7WE=?=

      #3
      Re: Replace extended ascii characters

      I've found a solution. str_replace works right, but the problem was
      that I get the string from a database and it seems that it was an
      strange character (ascii 194), that had to be next to ¡ or ¿ (ascii
      161 and 191), I don't know why, but....

      Now, to replace the ¡ and ¿, I must use
      str_replace(arr ay(chr(194).chr (161),chr(194). chr(191),"?","! "),"",
      $literal);


      Comment

      Working...