views:

76

answers:

2

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

+1  A: 

Use the iconv function:

 iconv('utf-8','iso-8859-1//TRANSLIT',$text);
turbod
Probably 'iso-8859-1//TRANSLIT', considering the later comment.
MSalters
A: 

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
please check the edit section in my question....
Avinash
@Avinash: `Â` is also in ISO 8859-1. That’s why it is not replaced.
Gumbo
What if I what to remove this? How can I remove this?
Avinash
@Avinash: Why do you want to remove it if it can be used with ISO 8859-1?
Gumbo
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
@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