4

Recently a record was inserted into my mysql database containing russian letters. The database couldn't display them properly. Is there anything I can do to allow diversity of languages on my website?

2
  • what was the data type of the column? Commented Nov 26, 2011 at 19:54
  • Retagged, removed encryption, changed into character-encoding. Commented Nov 26, 2011 at 20:04

2 Answers 2

2

you should take a look at utf8 encoding

can you please post what encoding is beeing used by your database, and your table? (can you post structure of your db?)

EDIT: To answer you question in your comment, basic difference is that utf8_general_ci is faster but doesn't care about some language specific comparisons. You can read more on this in the link I submitted above in my post. In fact it affects behaviour of sorting and searching.

It does matter how would you like your database to behave, all of these collations are useful in different environments. In your case I would not use utf8_bin since it only compares strings using it's binary values.

Sign up to request clarification or add additional context in comments.

4 Comments

I have a number of options to try for utf8. Would you suggest utf8_bin, utf8_generel_ci, or utf8_unicode_ci?
I've edited my post to answer your question in the comment, but I'd really read an article I posted here, I'd just have to rewrite the article to fully answer your question
Thank you for your help. Unfortunately what's happening now is when I look at the actual table, it displays the russian characters fine, but when it is displayed on my website, it is still showing a series of question marks.
this error usually happens when you don't specify encoding for your connection, I don't know which language do you use, for instance in php it's mysql_set_charset, in other languages you can find analogical functions/methods, but I think it's way out of this question (or we can move this to chat) to avoid spam
0

This is from long ago, but what helped me was to utf8_decode($variable) when executing the insert statements.

For example if I echo'd the query it would show the characters just fine, but when the query was executed the non-ASCII characters appeared garbled which made no sense. After doing the utf8_decode($variable) it worked.

Selecting nvarchar as column type may also help

example query:

$query = 'INSERT INTO table VALUES("'.utf8_decode($variable).'");';

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.