简体   繁体   中英

UTF-8 wrong character encoding

In one array there's a variable that has an é in it. I tried to replace it with a normal e using

echo strtr($var, "é", "e");

but even that doesn't work. It's weird. At the top of my page there's

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

then when I load the page the é character gets converted to [[#233]] and a plugin to convert things to pdf is saying to me that the document contains invalid UTF-8 character(s) . Anyone got a clue? The variable between comes from a latin1_swedish_ci database field.

That é being 00E9 sounds like Windows-1252 (CP1252). Not in the control range but I've had similar issues. Could use iconv to convert it and ensure valid UTF-8.

Before any query (select/insert/update) call this statement:

SET NAMES utf8;

Maybe you will need re-create your data in DB. Try to insert some new records and selected them.

Please check in database, In which Format é stored. if It Stored in this

&egrave;    &#232;  &#xE8;

format than you have to replace with this code.

It could be that your array was written in a file that was not encoded in UTF-8. The discrepancy between your page encoding and the encoding announced with the meta tag causes problem. Make sure you've got the right encoding configured in your text editor or IDE.

just add $html = iconv("UTF-8","UTF-8//IGNORE",$html); and pass this $html to your view

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