Why does wcwidth return -1 with a sign that I can print to the terminal?

Why does wcwidth here return "-1" (not the font width for printing) "Ԥ" (0x0524)?

 #include <stdio.h> #include <wchar.h> #include <locale.h> int wcwidth(wchar_t wc); int main() { setlocale(LC_CTYPE, ""); wchar_t wc1 = L'合'; // 0x5408 int width1 = wcwidth(wc1); printf("%lc - print width: %i\n", wc1, width1); wchar_t wc2 = L'Ԥ'; // 0x0524 int width2 = wcwidth(wc2); printf("%lc - print width: %i\n", wc2, width2); return 0; } Output:合 - print width: 2 Ԥ - print width: -1 
+4
source share
1 answer

Most likely U + 0524 was not a valid character when your libc character database was created. It was added in Unicode 5.2. Your font may already contain a character, but wcwidth does not look which font is being used.

+3
source

Source: https://habr.com/ru/post/1479103/


All Articles