#define _XOPEN_SOURCE #include #include #include #include #include int main (int argc, char *argv[]) { int num_char; wchar_t *wstring; if (argc > 1) { setlocale (LC_CTYPE, ""); num_char = mbstowcs (NULL, argv[1], 0) + 1; wstring = malloc ((num_char + 1) * sizeof (wstring[0])); mbstowcs (wstring, argv[1], num_char); printf ("length on screen of '%s' = %d\n", argv[1], wcswidth (wstring, num_char)); free (wstring); } }