14

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 ???????. ???????? ??? ?? ??????????? ?????????????? ????? ? ????????????? ??????? ??????. ? ???????, ? ??????? ? ?.?. 
Slava Vedenin
  • 58,326
  • 13
  • 40
  • 59
Mike
  • 6,854
  • 17
  • 53
  • 68
  • what is encoding used for the database? and where you are trying to display? – Vjy Nov 30 '10 at 16:58
  • Where is your output from? The data passes through various layers. Here is a link to similar questions so you can see the various parameters that mysql is influenced with http://stackoverflow.com/questions/3823278/fixing-encondings – Unreason Nov 30 '10 at 17:09

2 Answers2

14
  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.

Alex Logvin
  • 766
  • 10
  • 12
meder omuraliev
  • 183,342
  • 71
  • 393
  • 434
  • 3
    Ok, the important phrase of your reply way "make sure" .. :-) I had UTF-8 on the DB and the Tables, but what I found out, that I had fixed encoding to latin2 on the Columns. Thanks. :-) – Mike Nov 30 '10 at 17:38
  • 3
    You surely mean "collation", not "coallition" – Alexxus Jan 17 '14 at 10:07
4

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
Shubham Chopra
  • 1,678
  • 17
  • 30