ncurses and Unicode

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
Posts: 8
Joined: Sep 11, 2017 3:46

ncurses and Unicode

Postby Bad_Idea » Sep 12, 2017 8:56

Hello :)

I want to print unicode-characters with ncurses. I tried the following as suggested by several other forums:

Code: Select all

#Include Once ""
#Include Once "crt/"



The "addstr" will just print that string, "addch" prints nothing in this case (addch(34) works though) and "printw" prints garbage.
Posts: 1127
Joined: Feb 26, 2007 5:32

Re: ncurses and Unicode

Postby caseih » Sep 12, 2017 18:50

The FB compiler does not do string escaping by default, so \u notation does nothing as you found out. In general FB really has very little support for unicode. If your .bas file encoded in UTF-8 format you can put unicode characters in string literals, which become UTF-8 bytes. You should be able to do this, for example:

Code: Select all

print "┌"

Be sure to save the .bas file as UTF-8 text or it won't work right. In bytes, "┌" is chr(&he2, &h94, &h8c).

As far as ncurses go, ncurses also has little to no support for unicode. But it does work with bytes and since your terminal is already decoding utf-8 bytes, you can just pass utf-8 bytes to the ncurses functions and it should work because your terminal knows what to do with UTF-8 bytes. addch will not work with a unicode code point; you'll have to send it UTF-8 bytes individually instead.

Return to “Libraries”

Who is online

Users browsing this forum: No registered users and 1 guest