0

I have a chinese string 您好我的男人. When I copy and paste this in my ruby console to assign it to a variable I get this

i = \U+FFE7\U+FFE7\U+FFB7\U+FFE4\U+FFBA\U+FFBA

Very wierd issue.

PiKaY
  • 279
  • 4
  • 15
  • 1
    Works OK for me (Mac OS X, MRI Ruby 2.1.1, terminal using UTF-8). Also, if I map the characters codes via `x.chars.map {|c| c.ord.to_s(16) }` I see `["60a8", "597d", "6211", "7684", "7537", "4eba"]`, so that's what you should see if you get correct escaped Unicode pasted (e.g. you should see `i = "\U+60A8\U+....`). I think you need to give more details. Which Ruby version, which OS, and have you checked your terminal character encoding setting? – Neil Slater Jun 12 '14 at 06:55
  • I use ruby 1.9.3p448 and mac os x mountain lion – PiKaY Jun 12 '14 at 09:39
  • Seems to be a readline issue, see http://stackoverflow.com/questions/11116230/unicode-characters-in-ruby-1-9-3-irb-with-rvm and http://stackoverflow.com/questions/10385944/cant-enter-umlauts-in-ruby-1-9-3-irb – Stefan Jun 12 '14 at 14:41

1 Answers1

0

It is related to readline issue. Just reinstall your ruby version it will work.

Example you're working on ruby 1.9.3:

rbenv install 1.9.3

or

rvm reinstall 1.9.3
Hieu Le
  • 2,106
  • 1
  • 23
  • 23