1

I have a problem as below. I have one xml which contain utf-8 characters but the data of this xml will get displayed on page with iso encoding.

So I have to remove this utf-8 charactres from string, How can I do this.

Thanks Avinash

EDIT:

I have used : iconv("ISO-8859-1", "UTF-8", str_replace('&','and',removeEmptyLines(strip_tags($value))))

and now its displaying  in xml file.

How can I remove this...

hakre
  • 193,403
  • 52
  • 435
  • 836
Avinash
  • 6,064
  • 15
  • 62
  • 95

2 Answers2

1

Use the iconv function:

 iconv('utf-8','iso-8859-1//TRANSLIT',$text);
turbod
  • 1,988
  • 2
  • 17
  • 31
0

You can represent the Unicode characters with character references by using mb_convert_encoding:

mb_substitute_character('entity');
echo mb_convert_encoding($str, 'ISO-8859-1', 'UTF-8');

With mb_substitute_character you specify how invalid characters (characters of the input character set that are not present in the output character set) should be handled. In this case entity specifies to replace invalid characters by a corresponding HTML character reference.

Gumbo
  • 643,351
  • 109
  • 780
  • 844
  • @Avinash: `Â` is also in ISO 8859-1. That’s why it is not replaced. – Gumbo Aug 27 '10 at 10:03
  • What if I what to remove this? How can I remove this? – Avinash Aug 27 '10 at 10:04
  • @Avinash: Why do you want to remove it if it can be used with ISO 8859-1? – Gumbo Aug 27 '10 at 10:06
  • I don't know why but my database Collation is utf8_general_ci and when I fetch data its displaying This character in data. But when I look into the table using phpmyadmin. data have nothig like  in tabel. What can be the problem? – Avinash Aug 27 '10 at 10:08
  • @Avinash: There are more character encodings and collations that need to be considered. (See http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html) – Gumbo Aug 27 '10 at 10:47