Problem with adding a new record into MySQL DB

H

hongseok.yoon

MySQL DB's character-set is UTF8 and RoR(Ruby on Rails)'s database.yml
has a line 'encoding: utf8'.
If I add a new record using RoR's new action via Web Browser, Korean is
stored without problem.
If I set fiels explicitly like 'MyActionRecord['fieldname'] = '<some
Korean letters>', and invoke save method... yes, it works, but Korean
is not saved correctly. English was okay with same code.

How can I convert Korean letters to UTF8 characters? I did many tries
and finally I'm here.

irb(main):001:0> "한글" <-- I can't sure you guys can see this
letter. They are just two Korean letters.
=> "\307\321\261\333" <--- What the hell.....T^T
irb(main):002:0> "aaa" <--- English, of course.
=> "aaa" <--- No problem. - -

Please help...
 
P

Phillip Hutchings

MySQL DB's character-set is UTF8 and RoR(Ruby on Rails)'s database.yml
has a line 'encoding: utf8'.
If I add a new record using RoR's new action via Web Browser, Korean is
stored without problem.
If I set fiels explicitly like 'MyActionRecord['fieldname'] = '<some
Korean letters>', and invoke save method... yes, it works, but Korean
is not saved correctly. English was okay with same code.

Firstly you want the rails list at
http://lists.rubyonrails.org/mailman/listinfo/rails

Secondly chances are you're not sending your web pages with the
content-type set correctly. Use something like LiveHTTPHeaders for
Firefox (don't have a URL I'm sorry) and see if you get a line like
this:
Content-Type: text/html; charset=utf8

you're sending UTF8 encoded pages, if not then you need to send it.
I'm not sure on how to do this in Rails, see the Rails list.
 
L

Logan Capaldo

MySQL DB's character-set is UTF8 and RoR(Ruby on Rails)'s database.yml
has a line 'encoding: utf8'.
If I add a new record using RoR's new action via Web Browser, =20
Korean is
stored without problem.
If I set fiels explicitly like 'MyActionRecord['fieldname'] =3D '<some
Korean letters>', and invoke save method... yes, it works, but Korean
is not saved correctly. English was okay with same code.

How can I convert Korean letters to UTF8 characters? I did many tries
and finally I'm here.

irb(main):001:0> "=ED=95=9C=EA=B8=80" <-- I can't sure you guys can = see this
letter. They are just two Korean letters.
=3D> "\307\321\261\333" <--- What the hell.....T^T
irb(main):002:0> "aaa" <--- English, of course.
=3D> "aaa" <--- No problem. - -

Please help...


I can see it. :)
Secondly, the output from irb is the #inspect string. Try doing
puts "=ED=95=9C=EA=B8=80"

and see if that gives you what you expect. (Works good for me)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top