How to save Russian characters in a UTF-8 encoded file

我们两清 提交于 2019-11-28 13:03:09

if your doctype is html declare <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'> but if your doctype is xhtml then declare <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />.

Never assume that end-user will act correctly during your designs

If you already have some document, edit your document's meta tag for charset declaration and use notepad++ encoding>convert to UTF-8 without BOM, save your document, safely go on with your multilingual structure from now on.

php tag is irrelevant for your question since you don't mention about any database char setting.

If you want to tell browsers your encoding, place it inside your <header> tag:

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

Or short version

<meta charset='utf-8'>

That should be pretty enough for Russian characters to be correctly displayed on a webpage.

There is no difference between Latin and Cyrillic characters in UTF-8. Both are just byte sequences. Configure your server or PHP script to send Content-Type: text/html;charset=utf, and you are rather safe.

Your editor might have problems when the font you are using does not contain Russian characters. Choose another font then.

And please ignore the <meta> element recommendations. You don't need that: it is useless when your HTTP headers are correct, and maybe harmful if they aren’t.

Well you have to check 2 things

  • To ensure that *.php is an UTF-8 file I use PSPad. If file is not in UTF-8, I save it like that: http://stepolabs.com/upload/utf-8.png
  • Then your website must have UTF-8 encoding in <meta> tag;

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

    ... more about metatagging.

Finally if everything is done well - (format and meta declaration) all should be displayed properly!

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