13

While using Rails console, when I input ä, \U+FFC3\U+FFA4 appears. Of course I can input Unicode characters outside of rails.

I'm using Ruby 2.0.0p247, Rails 4.0.0 in Max OS X 10.7.5.

How can I input Unicode characters in Rails console?

ironsand
  • 14,329
  • 17
  • 83
  • 176
  • Thanks, but I can input unicode character in terminal without problem. I can't input only in rails console. – ironsand Nov 08 '13 at 11:14
  • Do you use rvm? Most likely you've got readline issue, https://github.com/wayneeseguin/rvm/issues/1016 or http://blog.rlmflores.me/blog/2012/04/25/adding-utf-8-support-to-rubies-compiled-through-ruby-build/ – dimuch Nov 08 '13 at 11:48
  • I'm using rbenv, but as you said readline was the problem. I reinstall the ruby and works fine now! Could you write it as a answer so that I can accept it. – ironsand Nov 08 '13 at 12:50

2 Answers2

16

I did have the same problem. After done a lot of things, including the complete reinstall of RVM, I'd realized I just need to define the LC variables. To do the same, run these commands on terminal:

LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
export LANG LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LC_ALL

One good idea is save this code in .bash_profile or .bashrc files in the App folder.

Fernando Kosh
  • 3,426
  • 1
  • 34
  • 31
2

Most likely you've got readline issue, try to re-install Ruby with readline support. https://github.com/wayneeseguin/rvm/issues/1016 or http://blog.rlmflores.me/blog/2012/04/25/adding-utf-8-support-to-rubies-compiled-through-ruby-build/

dimuch
  • 12,728
  • 2
  • 39
  • 23