Question

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) ?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top