Carlos
12/22/2004 12:18:00 PM
[Simon Strandgaard <neoneye@gmail.com>, 2004-12-22 08.29 CET]
> > On the other hand, the parameters to "addn?wstr" are wchar_t *, which I
> > think are defined as 32 bit integers. So I guess you should either use
> > "pack('L*')", or change the function declaration.
>
>
> Using addwstr with pack("L*") doesn't seem to work for me either.
> How would a good representation of wchar_t string be like?
On the other other hand, I've found that if you use the functions without
"w", you can output UTF-8 strings directly :). It's more easy so...
And I've also found the secret to make ncursesw print non-ascii characters:
set the locale LC_ALL to "".
This works:
#
# Using ncurses-5.4 with --enable-widec --with-shared
#
require 'dl/import'
module Curses
extend DL::Importable
dlload "libncursesw.so"
typealias "WINDOW", "void*"
extern "int addstr(const char *)"
extern "int cbreak()"
extern "int endwin()"
extern "int getch()"
extern "WINDOW initscr()"
extern "int noecho()"
extern "int refresh()"
extern "int addstr(const char *)"
extern "int addnstr(const char *, int)"
end
module LibC
extend DL::Importable
dlload "libc.so.6"
extern "void setlocale(int, const char *)"
end
LibC.setlocale(6, "") # LC_ALL == 6
str = [0x250c, 0x2510, 10, 0x2514, 0x2518, 0].pack("U*")
Curses.initscr
Curses.cbreak
Curses.noecho
Curses.addstr(str) # a box..
Curses.addstr("simple UTF-8 string ¿â?â??â??â??? ¡â??!\000")
Curses.getch
Curses.endwin
__END__
Good luck.