PDA

View Full Version : unicode on ncurses



johnny3k
May 11th, 2011, 07:57 AM
#include <ncurses.h>
// compile and link: gcc <program file> -lncurses
int main()
{
initscr(); /* Start curses mode */
printw("Привет мир!"); /* Print Hello World */
refresh(); /* Print it on to the real screen */
getch(); /* Wait for user input */
endwin(); /* End curses mode */
return 0;
}

ubuntu@ubuntu-machine:~/projects/ncurses$ g++ hello.cpp -o hello -lncurses
ubuntu@ubuntu-machine:~/projects/ncurses$ ./hello && rm hello
�~_�~@иве�~B ми�~@!

It possible to use Unicode strings on ncurses? :popcorn:

johnny3k
May 11th, 2011, 08:45 AM
#include <linncursesw.h>
hello.cpp:2:26: fatal error: linncursesw5.h: Нет такого файла или каталога
compilation terminated. // there is not this file or catalog

#include <ncursesw.h>
say there is not this file or catalog

nvteighen
May 11th, 2011, 01:14 PM
Look at this post: http://ubuntuforums.org/showpost.php?p=5518749&postcount=2

Be sure you've installed libncursesw5-dev.

johnny3k
May 11th, 2011, 02:59 PM
i have good news. it's compile with success :D, but i cannot see unicode text :(




// http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/helloworld.html
#include <locale.h>
#include <ncursesw/ncurses.h>
int main(int argc, char *argv[])
{
setlocale(LC_ALL,"");
initscr();
curs_set(0); //remove cursor
printw("Привет мир !!!");
refresh(); //update screen
getch(); //wait for input
endwin();
return 0;
}

ubuntu@ubuntu-machine:~/projects$ g++ code01.cpp -o code01 -lncurses
ubuntu@ubuntu-machine:~/projects$ ./code01
M-P~_M-Q~@M-PM-8M-PM-2M-PM-5M-Q~B M-PM-<M-PM-8M-Q~@ !!!

Arndt
May 11th, 2011, 03:31 PM
i have good news. it's compile with success :D, but i cannot see unicode text :(

I haven't tried it, but can you link using -lncursesw instead?

johnny3k
May 11th, 2011, 04:16 PM
Thanks! It's working!