sid_com
sid_com

Reputation: 25117

How to print Unicode with NCurses?

This prints

�~X�

How could I get the unicode instead?

#!/usr/bin/env perl6
use v6;
use NCurses;

my $win = initscr;
my Str $s = "\x[263a]";
printw( $s );
nc_refresh;
while getch() < 0 {};
endwin;

Upvotes: 5

Views: 536

Answers (1)

Marty
Marty

Reputation: 2808

I was getting the same as you - turns out just needed to set locale;

#!/usr/bin/env perl6
use v6;
use NCurses;

use NativeCall;
my int32 constant LC_ALL = 6;          # From locale.h
my sub setlocale(int32, Str) returns Str is native(Str) { * }

setlocale(LC_ALL, "");
my $win = initscr;
my Str $s = "\x[263a]";
printw( $s );
nc_refresh;
while getch() < 0 {};
endwin;

That puts a smile on my face... and screen. ☺

Upvotes: 4

Related Questions