IRB escapes UTF characters

百般思念 提交于 2019-12-08 04:31:10

问题


I'm using OS-X (10.10.5) and rbenv (1.0.0) Ruby (2.2.4p230) and Fish Shell (2.2.0).

When I type non ASCII characters in irb they are automatically escaped.

max@MaxBook ~/p/sandbox> echo "Ö"
Ö
max@MaxBook ~/p/sandbox> irb 
irb(main):001:0> \U+FFC3\U+FFB6

I though at first this could be a problem with the shell or my Terminal settings but it only happens in IRB. Changing shells or ruby versions does not effect it.

I did not have this problem on my previous laptop which had an almost identical configuration. What is going on here?


回答1:


You can enable unicode support in IRB by recompiling Ruby against readline (instead of libedit which would be the default).

First install readline for example with brew:

brew install readline

I use rbenv to manage Ruby versions and use the following line to install Ruby versions:

RUBY_CONFIGURE_OPTS=--with-readline-dir="$(brew --prefix readline)" rbenv install 2.3.1

With rvm it will look like:

rvm install 2.3.1 --with-readline-dir=$rvm_path/usr

Or when you might want to recompile Ruby from source, then this answer might help you.



来源:https://stackoverflow.com/questions/37479850/irb-escapes-utf-characters

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!