Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4 |
both |
#include <wchar.h>
int wcwidth(const wint_t wc);
#define _XOPEN_SOURCE
#include <wchar.h>
int wcwidth(const wchar_t wc);
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.
Special behavior for XPG4: If you define any feature test macro specifying XPG4 behavior before the statement in your program source file to include the wchar header, then the compiler assumes that your program is using the XPG4 variety of the wcwidth() function. Please see Table 1 for a list of XPG4 and other feature test macros.
int wcwidth(const wchar_t wc);
The difference between this variety and the C/370™, non-XPG4 variety of the wcwidth() function is that its parameter, wc, is a wchar_t rather than a wint_t type.
If successful, wcwidth() returns the number of printing positions occupied by wc.
If wc is a NULL or non-spacing wide character, wcwidth() returns 0.
If wc is not a printing wide character, wcwidth() returns -1.
⁄* CELEBW31 *⁄
#include <stdio.h>
#include <wchar.h>
int main(void)
{
wint_t wc = L'A';
printf("wc has a width of: %d\n", wcwidth(wc));
}
wc has a width of: 1