Bad UTF-8 without BOM encoding

∥☆過路亽.° 提交于 2019-12-21 14:59:30

问题


I converted all my files to UTF-8 without BOM encoding using Notepad++. I have no problem with BOMs anymore but the UTF without BOM encoding is simply not working, it's as if my site was encoded in ANSI. All special characters display either as: Â, Ú or á.

What can be the reason for this and how can I fix it?

http://chusmix.com/?ciudad=Pilar

Thanks


回答1:


You have to tell the browser to accept it as UTF-8 so it will properly parse multibyte characters. Add this meta tag in your <head> tag with the rest of your metas:

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />

Update

For HTML5, use this tag instead:

<meta charset="utf-8">




回答2:


you will need to tell your web server to tell the client that now everything is utf-8...

There are 2 options to do this:

  • HTTP header this is a setting of the web server itself Content-Type: text/html; charset=UTF-8

  • Meta tags this is something you could put into your html files header <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

see http://www.w3.org/International/O-HTTP-charset.en.php?changelang=en

you can check your site for problems regarding charset and other things here




回答3:


The HTML code doesn't contain any encoding, so the browser probably interprets it as ISO-LATIN, not UTF-8. Check out Setting the HTTP charset parameter at the W3 consortium.




回答4:


Send a header informing the browser what character set a document is encoded in:

header('Content-Type: text/html; charset=UTF-8');


来源:https://stackoverflow.com/questions/7102935/bad-utf-8-without-bom-encoding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!