我目前正在使用这段代码来测试控制台,但是unicode字符总是完全损坏的(在1.9和1.8.7中甚至更多)
# encoding: UTF-8
require 'curses'
Curses.noecho # do not show typed chars
Curses.nonl # turn off newline translation
Curses.stdscr.keypad(true) # enable arrow keys
Curses.raw # give us all other keys
Curses.stdscr.nodelay = 1 # do not block -> we can use timeouts
Curses.init_screen
count = 0
loop do
key = Curses.getch || 4294967295
next if key == 4294967295
exit if key == 3 # Ctrl+c
count = (count + 1) % 20
Curses.setpos(count,0)
Curses.addstr("#{key.inspect} äáßðäëéßðf ");
end你知道如何从根本上解决这个问题( 1.8或1.9)吗?
发布于 2011-01-16 05:23:43
我不知道具体的步骤,但我听说人们说他们必须使用libncursesw5-dev重新编译Ruby,才能使Unicode按预期工作。
https://stackoverflow.com/questions/4702103
复制相似问题