gpt4 book ai didi

ruby - 如何使用 curses 显示 unicode 字符?

转载 作者:太空宇宙 更新时间:2023-11-03 16:38:00 25 4
gpt4 key购买 nike

我目前正在将此代码用于测试控制台,但 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 上)吗?

最佳答案

我不知道确切的步骤,但我听说有人说他们必须使用 libncursesw5-dev 重新编译 Ruby 才能使 Unicode 正常工作。

关于ruby - 如何使用 curses 显示 unicode 字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4702103/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com