Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
544 views
in Technique[技术] by (71.8m points)

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

OK so I have a PHP file with several strings of text in various languages. For most languages like French or Spanish I just simply type in the characters.

The problem I have is with Russian language characters. The PHP file is encoded in UTF-8, how can I make sure that the Russian characters are both saved correctly and displayed correctly on the output web page... Is it just a case of pasting the text into the PHP file, or is there a way to guarantee the characters will be saved into the file correctly - perhaps converting it into HTML-like notation for example?

Obviously I am assuming the end user will have the correct encoding set in their web browser, I just want to make sure I got it all covered from my end.

I am using Notepad++ on Windows to edit my PHP file.

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...