MySQL - Russian characters display incorectly
I have to make an russian version of a website, but I can't find out, how to insert russian characters into Database.
I tryed almost every possible coding, but it only shows:
???????? ?????????? ??????? ??????? ? ????? ?? ????????????? ? ???????, ??????? ????? ??????? ???????? ????? .??? ??????????? ???????? ????? ?? ????? ?????????? ? ????? ????????.
??????????? ?????? ?? ???????? ????? ?? 20 ???????. ???????? ??? ?? ??????????? ?????????????? ????? ? ????????????? ??????? ??????. 开发者_如何学JAVA? ???????, ? ??????? ? ?.?.
- Make sure the database charset/collation is UTF-8
- On the page you insert these russian characters ( the form, textarea ), make sure the encoding is UTF-8, by setting Content-Type to
text/html; charset=utf-8
. Enter in russian text directly to the form input. - On the processing page that handles this form, which inserts it into the database, make sure to do
SET NAMES utf8
so it's stored as UTF-8 before you insert the data, in a separate query beforehand. - When you render the content from the database in a view, make sure the
Content-Type
istext/html; charset=utf-8
.
Make sure that the content-type is not windows-1251 or iso-8859-1/latin1. Make sure the database charset/collation is NOT ISO-8859-1/Latin1.
For storing russian characters in db your db should support UTF-8 encoding. Modify your table with below query to enable UTF-8 encoding.
ALTER TABLE t1 CONVERT TO CHARACTER SET utf8
精彩评论