【发布时间】:2011-01-15 20:58:52
【问题描述】:
我目前正在将此代码用于测试控制台,但 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 上)吗?
【问题讨论】:
标签: ruby ruby-1.9 curses ruby-1.8