Jump to content

How to save russian/cyrillic letter properly to db?


ts2000abc

Recommended Posts

When I try to save russian letters to database through my own UI (normal html form that is posted to php), mysql automatically converts these letter.

Example:
д  converts to &#1076 

 

I would like to save these russian/cyrillic letters as ”normal” text (not as converted special characters).

 

When I use phpmyadmin to save russian letters straight into db everything goes just fine, letters are not converted (and they can be viewed ok). So I assume that there is something wrong with the my saving process... can anybody tell me how this situation is fixed.

 

- Which database and table setting should I use?

(now i use: CHARSET=utf8 COLLATE=utf8_unicode_ci)

 

- Should I convert the input data somehow (php: iconv() for example)?

 

- Should I use some special database connection setting when saving? (specify charset for example)

 

 

Well, it sounds like your webpage is not utilizing the UTF-8 characters set, but rather has fallen back to something like 8859-1.  This is causing the site to convert input into html entities. Hence you are getting the html entity rather than the real utf-8 character stored in your database.  You can test this quickly by setting the header:

 

header('Content-Type:text/html; charset=UTF-8');

 

Does this fix the problem?

 

Ultimately the default character set can also be set in the php.ini. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.