allglyph: don't print UTF-16 surrogate characters #740

pull/747/head
nick black 4 years ago
parent d568e0619c
commit 5513707d8d
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -24,15 +24,19 @@ allglyphs(struct notcurses* nc, struct ncplane* column, int legendy){
for(long int c = 0 ; c < 0x10000l ; ++c){
const char32_t wc = *plane * 0x10000l + c;
wchar_t w[2] = { wc, L'\0', };
// surrogates are meaningful only for UTF-16
if(wc >= 0xd800 && wc <= 0xdfff){
continue;
}
if(wcwidth(w[0]) >= 1){
int x;
if(ncplane_putwegc(column, w, NULL) < 0){
return -1;
}
ncplane_cursor_yx(column, NULL, &x);
if(ncplane_printf_aligned(std, legendy, NCALIGN_CENTER, "0x%06x", wc) < 0){
return -1;
}
ncplane_cursor_yx(column, NULL, &x);
if(x >= dimx){
DEMO_RENDER(nc);
ncplane_set_fg_rgb(column,
@ -64,6 +68,8 @@ int allglyphs_demo(struct notcurses* nc){
if(ncplane_highgradient(n, tl, tr, bl, br, dimy - 1, dimx - 1) < 0){
return -1;
}
ncplane_set_fg(n, 0xf0f0a0);
ncplane_set_bg(n, 0);
int width = 40;
if(width > dimx - 8){
if((width = dimx - 8) <= 0){

Loading…
Cancel
Save