diff --git a/src/demo/unicodeblocks.c b/src/demo/unicodeblocks.c index 9e50b25c1..811d7b6c3 100644 --- a/src/demo/unicodeblocks.c +++ b/src/demo/unicodeblocks.c @@ -58,20 +58,19 @@ draw_block(struct ncplane* nn, uint32_t blockstart){ for(chunk = 0 ; chunk < BLOCKSIZE / CHUNKSIZE ; ++chunk){ int z; for(z = 0 ; z < CHUNKSIZE ; ++z){ - wchar_t w[2] = { blockstart + chunk * CHUNKSIZE + z, L'\0' }; + wchar_t w = blockstart + chunk * CHUNKSIZE + z; char utf8arr[MB_CUR_MAX * 3 + 5]; - if(wcswidth(w, INT_MAX) >= 1 && iswgraph(w[0])){ + if(wcwidth(w) >= 1 && iswgraph(w)){ mbstate_t ps; memset(&ps, 0, sizeof(ps)); - const wchar_t *wptr = w; - int bwc = wcsrtombs(utf8arr, &wptr, sizeof(utf8arr), &ps); + int bwc = wcrtomb(utf8arr, w, &ps); if(bwc < 0){ fprintf(stderr, "Couldn't convert %u (%x) (%lc) (%s)\n", blockstart + chunk * CHUNKSIZE + z, - blockstart + chunk * CHUNKSIZE + z, w[0], strerror(errno)); + blockstart + chunk * CHUNKSIZE + z, w, strerror(errno)); return -1; } - if(wcwidth(w[0]) < 2){ + if(wcwidth(w) < 2){ utf8arr[bwc++] = ' '; } utf8arr[bwc++] = 0xe2;