Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to input Unicode character in Rails console?

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?

like image 707
ironsand Avatar asked Nov 08 '13 11:11

ironsand


People also ask

How to insert Unicode character in a string?

Inserting Unicode characters To insert a Unicode character, type the character code, press ALT, and then press X. For example, to type a dollar symbol ($), type 0024, press ALT, and then press X. For more Unicode character codes, see Unicode character code charts by script.

What is meant by Unicode Class 11?

Unicode is a universal character encoding standard. This standard includes roughly 100000 characters to represent characters of different languages. While ASCII uses only 1 byte the Unicode uses 4 bytes to represent characters. Hence, it provides a very wide variety of encoding.


1 Answers

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.

like image 55
Fernando Kosh Avatar answered Oct 10 '22 17:10

Fernando Kosh