Pergunta

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 ???????. ???????? ??? ?? ??????????? ?????????????? ????? ? ????????????? ??????? ??????. ? ???????, ? ??????? ? ?.?. 
Foi útil?

Solução

  1. Make sure the database charset/collation is UTF-8
  2. 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.
  3. 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.
  4. When you render the content from the database in a view, make sure the Content-Type is text/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.

Outras dicas

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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top