如何在 rails 控制台(或 irb)中输入多字节字符? [英] How can I input multibyte characters in rails console (or irb)?
问题描述
伙计们.我正在用 rails 开发一个中文应用程序.现在我想在 rails 控制台中输入一些汉字,但在 irb 中不能这样做.
guys. I am developing a Chinese application with rails. Now I want to input some Chinese characters in rails console but cannot do that, either in irb.
有经验的人解决这个问题吗?感谢您的帮助!
Any guys who have the experience to solve this problem? I would appreciate your help!
推荐答案
我找到了解决方案,需要重新编译 readline.现在我可以输入非 ASCII 字符了!
I found the solution for me, it need to re-compile the readline. And now I can input non-ASCII characters!
因为我用的是rvm,所以找了这篇文章教大家如何在rvm下重新编译readline.http://rvm.beginrescueend.com/packages/readline/
Because I am using rvm, so I found this article to teach you how to re-compile readline under rvm. http://rvm.beginrescueend.com/packages/readline/
对于不使用 rvm 的人,也许您可以关注这篇文章并尝试一下:http://henrik.nyh.se/2008/03/irb-readline
And for someone who is not using rvm, maybe you can follow this post and have a try: http://henrik.nyh.se/2008/03/irb-readline
顺便说一下,ruby-1.9.2 irb 已经支持非 ASCII 输入了.
By the way, ruby-1.9.2 irb already supports non-ASCII inputing.
这篇关于如何在 rails 控制台(或 irb)中输入多字节字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!