如何使用curses显示unicode字符?
我目前正在使用此代码作为测试控制台,但 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 上)吗?
I am currently using this code for a test console, but unicode chars are always completely broken (even more in 1.9 then 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
any idea how to even partyally fix this (on 1.8 or 1.9) ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道确切的步骤,但我听人们说他们必须使用 libncursesw5-dev 重新编译 Ruby 才能使 Unicode 按预期工作。
I don't know the exact steps, but I've heard people say that they had to recompile Ruby using libncursesw5-dev to get Unicode to work as expected.