简体   繁体   中英

how to remove all utf-8 characted from string using php

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

使用iconv函数:

 iconv('utf-8','iso-8859-1//TRANSLIT',$text);

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM