# Encoding problem with rails 1.2 and MySql 5.0

**URL:** <https://www.ruby-forum.com/t/encoding-problem-with-rails-1-2-and-mysql-5-0/92701>\
**Category:** Rails\
**Created:** [April 23, 2007, 6:25am UTC](https://www.ruby-forum.com/t/encoding-problem-with-rails-1-2-and-mysql-5-0/92701 "2007-04-23T06:25:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![allen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bbce88/32.png) [@allen](https://www.ruby-forum.com/u/allen)\
**Post date:** [April 23, 2007, 6:25am UTC](https://www.ruby-forum.com/t/encoding-problem-with-rails-1-2-and-mysql-5-0/92701/1 "2007-04-23T06:25:26Z")

</div>

Hi all,

I want my rails application and ferret to support utf-8, so I create a  
database in MySql 5.0 using utf-8 charset and add the following  
declarations in environment.rb:

$KCODE = ‘u’  
require ‘jcode’  
ENV[‘LANG’] = ‘zh\_CN.utf8’  
require ‘acts\_as\_ferret’

After that, I enter some chinese characters from the web page I’ve  
created. Everything is OK, I can see all the text in the correct  
encoding. But as I turn to my database and check the data in the  
tables, I can only see some meaningless characters(while these  
meaningless characters can be showed correctly in the web pages).  
Further more, if I enter some data directly to the database, the web  
pages will show these data as a group of “?”. I think there must be  
something wrong with the encoding setting but I cannot tell what it  
is. Anybody know how to solve this? Thanks very much.
