Syntax
#include <wchar.h> int wcwidth (const wint_t wc);Description
wcwidth determines the number of printing positions that a graphic representation of wc occupies on a display device. Each of the printing wide characters occupies its own number of printing positions on a display device. The number is independent of its location on the device.
The behavior of wcwidth is affected by the LC_CTYPE category.
wcwidth returns the number of printing positions occupied by wc. If wc is a null wide character, wcwidth returns 0. If wc is not a printing wide character, wc returns -1.
This example determines the printing width for the wide character A.
#include <stdio.h>
#include <wchar.h>
int main(void)
{
wint_t wc = L'A';
printf("%lc has a width of %d\n", wc, wcwidth(wc));
return 0;
/****************************************************************************
The output should be similar to :
A has a width of 1
****************************************************************************/
}
Related Information