ncursesで日本語
Rubyのcursesライブラリで試したのだけど、日本語が表示できない…ncurseswというキーワードも発見したのだけど、ヨーワカラン…
試したコード:
require "curses" include Curses init_screen begin win = stdscr.subwin(5,30,2,2) win.box(?|,?-,?*) win.setpos(2,2) win.addstr("ほげほげ") win.refresh getch ensure close_screen end
実行結果:
*----------------------------* | | | ?~A??~A~R?~A??~A~R | | | *----------------------------*
win.addwstrというメソッドはなかった…。うむむ。
解決!
#include
#include <stdlib.h> #include <ncurses.h> #include <locale.h> int main(void) { setlocale( LC_ALL, "" ); initscr(); cbreak(); noecho(); scrollok( stdscr, false ); keypad( stdscr, true ); addstr("ほげほげ"); refresh(); sleep(1); endwin(); return 0; }