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)

 

 

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.